Commit Graph

109 Commits (58a36cb651bc6bfda1f893938e5278b34c28caa0)

Author SHA1 Message Date
Aaron Lehmann 2b996b6038 wal: Export SegmentSizeBytes as a variable
In test situations, it's useful to create smaller than usual WAL files
to test rotation and to avoid the overhead of preallocation on old-style
filesystems that don't handle it efficiently. This commit changes
segmentSizeBytes to an exported variable so that tests can override it
from an init() function.
2016-08-09 15:38:30 -07:00
Anthony Romano 5991209c2d wal: release wal locks before renaming directory on init
Fixes #5852
2016-07-02 12:14:37 -07:00
Gyu-Ho Lee 6cfc03a5f9 wal: use CreateDirAll 2016-06-22 15:57:55 -07:00
Gyu-Ho Lee b4aa4607cb wal: use bytes.Equal, other minor updates
- Replace reflect.Equal with bytes.Equal where possible
- Remove some TODOs
- Some minor simplifications
2016-06-13 01:33:53 -07:00
Gyu-Ho Lee 3243795522 wal: simplify boolean return 2016-06-11 10:36:52 -07:00
Gyu-Ho Lee 4570eddc2c wal: PrivateFileMode/DirMode as in pkg/fileutil
To make it consistent with pkg/fileutil
2016-06-10 15:20:57 -07:00
Anthony Romano 39eaa37dcf wal: warn if sync exceeds a second 2016-06-08 11:03:18 -07:00
Anthony Romano 5be39d2c84 wal: don't preallocate on old tail file
Code is only there to handle an edge case where the tail wasn't preallocated
already (e.g., via old etcd version or a crash). It also triggers tmpfs
corruption, so remove it.
2016-06-06 11:31:25 -07:00
Anthony Romano 71a9d6fc8b wal: don't warn when opening wal directory with stale tmp files 2016-05-31 06:25:23 -07:00
Gyu-Ho Lee 4a5befc2de wal: update LICENSE header 2016-05-12 20:50:04 -07:00
Anthony Romano 17391336af wal: atomically initialize wal directory
Fixes #5270
2016-05-11 16:50:17 -07:00
Xiang Li 0fb7cb8b00 *: add disk operation metrics for monitoring 2016-05-11 09:36:45 -07:00
Anthony Romano bfe3a3d08e wal: fix tail corruption
On ReadAll, WAL seeks to the end of the last record in the tail. If the tail did not
end with preallocated space, the decoder would report 0 as the last offset and begin
writing at offset 0 of the tail.

Fixes #4903
2016-04-01 15:05:52 -07:00
Anthony Romano bd832e5b0a *: migrate Godeps to vendor/ 2016-03-22 17:10:28 -07:00
Anthony Romano 0df732c052 wal: pre-create segment files
Pipeline file creation and allocation so it overlaps writes to the log.

Fixes #4773
2016-03-21 11:56:53 -07:00
Anthony Romano 24b806d2ee wal: preallocate WAL files with initial size equal to segment size
Avoids having to update file size metadata during fdatasync on common path.

Fixes #4755
2016-03-21 11:56:53 -07:00
Anthony Romano aafe717f2f fileutil: support file extending preallocate 2016-03-21 09:42:30 -07:00
Anthony Romano 7397e14c0a fileutil, wal: refactor file locking
File lock interface was more verbose than it needed to be while
simultaneously making it difficult to support systems (e.g., Windows)
that only permit locked writes on a single fd holding the lock.
2016-03-16 15:02:15 -07:00
Xiang Li 53e7ddbc66 wal: do not call fsync when it is not necessary 2016-03-14 11:52:06 -07:00
Xiang Li e59efe45a1 wal: support fadatasync on linux 2016-03-13 17:22:53 -07:00
Gyu-Ho Lee 71c2a9bb3c *: fix minor typos, comments 2016-01-30 18:15:56 -08:00
Gyu-Ho Lee a4de207d53 wal: fix shadowed variables
Fixes for https://github.com/coreos/etcd/issues/3954.
2015-12-12 09:38:26 -08:00
Gyu-Ho Lee 55adfcb428 wal: minor typo in wal pkg
Fixes a minor typo in wal.go.
Thanks!
2015-11-12 15:23:12 -08:00
Xiang Li 1c7f52d931 wal: use Histogram for syncDuration 2015-10-17 12:45:43 -07:00
Xiang Li 39a4b6a5e5 pkg/fileutil: support perallocate 2015-08-06 10:10:58 -07:00
Hitoshi Mitake ba76e27875 wal: log errors in wal.Close()
This patch adds error logging in wal.Close() if unlocking and
destroying fail. Though it is hard to handling the errors, logging
would be helpful for trouble shooting.
2015-08-05 15:03:45 +09:00
Xiang Li f59da0e453 *:fix point-in-time backup
Backup process should be able to read all WALs until io.EOF to
generate a point-in-time backup.

Our WAL file is append-only. And the backup process will lock all
files before start reading, which can prevent the gc routine from
removing any files in the middle.
2015-06-15 11:12:28 -07:00
Xiang Li 711451ce2d *: rename logger to plog 2015-06-02 14:58:24 -07:00
Xiang Li 185d2bced4 wal: use leveled logger 2015-06-01 13:38:50 -07:00
Xiang Li 89242d4659 wal: better log msg 2015-04-09 09:54:20 -07:00
Xiang Li 53792ccbdc wal: never leave a corrupted wal file
If the process dies during wal.cut(), it might leave a corrupted wal
file. This commit solves the problem by creating a temp wal file first,
then atomically rename it to a wal file when we are sure it is vaild.
2015-04-08 15:57:20 -07:00
Yicheng Qin 44de670de7 wal: allow at most one WAL function called at one time
SaveSnap and Save are called in separate goroutines now. Allow at most
one WAL function being called at one time to protect internal fields and
guarantee execution order.
Or one possible bug is that the new cut file is started with snapshot
entry instead of crc entry.
2015-04-08 00:34:30 -07:00
Xiang Li c32cca3a4f wal: reduce allocation when encoding entries 2015-03-30 19:20:46 -07:00
Xiang Li 8b4eed29e5 wal: fix the unexpectedEOF error in the last wal.
It is safe to repair the unexpectedEOF error in the last wal. raft
will not send out message before the entry successfully comitted
into wal. Thus we can safely truncate the last entry in the wal
to repair.
2015-03-28 21:08:14 -07:00
Xiang Li 6e6669d696 wal: releastTo should work with large release index 2015-03-24 22:34:26 -07:00
Xiang Li b66eb3d81c wal: fix ReleaseLockTo
ReleaseLockTo should not release the lock on the WAL
segment that is right before the given index. When
restarting etcd, etcd needs to read from the WAL segment
that has a smaller index than the snapshot index.

The correct behavior is that ReleaseLockTo releases
the locks w is holding so that w only holds one lock
that has an index smaller than the given index.
2015-03-09 19:52:54 -07:00
Xiang Li 86429264fb wal: support auto-cut in wal
WAL should control the cut logic itself. We want to do falloc to
per allocate the space for a segmented wal file at the beginning
and cut it when it size reaches the limit.
2015-02-28 11:18:59 -08:00
Xiang Li 84485643fe *: expose wal metrics at /metrics 2015-02-28 11:06:11 -08:00
Xiang Li fb1a28c65d *: vendor prometheus 2015-02-28 11:06:11 -08:00
Xiang Li 9e63b1fb63 wal: record metrics 2015-02-28 10:12:35 -08:00
Yicheng Qin e966e565c4 etcdctl/backup_command: handle datadir with missed snapshot mark
This helps to recover from the data dir created in v2.0.0-rc1.
2015-01-29 13:32:59 -08:00
Jonathan Boulle f1ed69e883 *: switch to line comments for copyright
Build tags are not compatible with block comments.
Also adds copyright header to a few places it was missing.
2015-01-26 09:53:30 -08:00
Yicheng Qin 270e67db84 wal: not export unnecessary public functions 2015-01-09 14:55:10 -08:00
Yicheng Qin 6460e49a33 wal: save empty snapshot when create
So caller can open at empty snapshot to read all entries.
2015-01-06 19:48:21 -08:00
Yicheng Qin 84f62f21ee wal: record and check snapshot 2015-01-06 16:27:40 -08:00
Jonathan Boulle 1ec98cb795 pkg/fileutil: sort filenames during ReadDir 2014-12-18 16:36:11 -08:00
Xiang Li 53bf7e4b5e wal: rename openAtIndex -> open; OpenAtIndexUntilUsing -> openNotInUse 2014-12-14 19:33:06 -08:00
Xiang Li f538cba272 *: do not backup files still in use 2014-12-14 19:27:22 -08:00
Xiang Li ea94d19147 *: lock the in using files; do not purge locked the wal files 2014-12-14 19:27:22 -08:00
Yicheng Qin b9bf957c6d wal: sync after writing data to disk in Cut function 2014-12-04 22:56:34 -08:00