44 Commits

Author SHA1 Message Date
Benjamin Wang
1fe7b9793a etcdserver: add failpoints walBeforeSync and walAfterSync
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-02-08 09:08:09 +08:00
Benjamin Wang
bd9f1584d4 process the scenaro of the last WAL record being partially synced to disk
We need to return io.ErrUnexpectedEOF in the error chain, so that
etcdserver can repair it automatically.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-01-08 04:46:51 +08:00
Piotr Tabor
8ec3cbc551 fixup! Add --raw mode to ./etcd-dump-log
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 09:22:39 +01:00
Piotr Tabor
e571fb7baa Add --raw mode to ./etcd-dump-log
This mode allows to look at RAW protos for all entries in WAL logs in the given directory.

Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 09:22:34 +01:00
Piotr Tabor
58681d3feb Expose types of entries within the WAL log for access from the tools.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 09:19:23 +01:00
Piotr Tabor
0d8aad54ba wal: Expose Decoder as package visible interface.
Such that can be used by tools.

Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 09:19:23 +01:00
Piotr Tabor
bee2a08968 wal decoding: Add optional mode to ignore CRC errors.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 09:19:23 +01:00
Piotr Tabor
498619bdda wal decoder: report file & offset in case of CRC mismatch.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-30 09:19:23 +01:00
Piotr Tabor
9abc895122 Goimports: Apply automated fixing to test files as well.
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-29 13:04:45 +01:00
Piotr Tabor
9e1abbab6e Fix goimports in all existing files. Execution of ./scripts/fix.sh
Signed-off-by: Piotr Tabor <ptab@google.com>
2022-12-29 09:41:31 +01:00
Benjamin Wang
cc58edecf2 raft: add raft into the tools/mod
Previously etcdservers depends on raft/raftpb/raft.proto directly.
After moving raft to a separate repo, we need to add raft to the
tools/mod, and get raft included in the -I protc flags.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-02 15:36:41 +08:00
Benjamin Wang
faff80a2b3 etcdserve: format the source code
gofmt -w ./server

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-02 13:00:59 +08:00
Benjamin Wang
e9aa275b36 etcdserver: update etcdserver to use the new raft module go.etcd.io/raft/v3
Just replaced all go.etcd.io/etcd/raft/v3 with go.etcd.io/raft/v3
under directory server.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-02 09:33:45 +08:00
Benjamin Wang
686846ec65 add more debug info for opening WAL files failure
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-11-28 18:58:01 +08:00
Bhargav Ravuri
2feec4fe68 comments: fix comments as per goword in go test files
Comments fixed as per goword in go test files that shell
function go_srcs_in_module lists as per changes on #14827

Helps in #14827

Signed-off-by: Bhargav Ravuri <bhargav.ravuri@infracloud.io>
2022-11-23 23:05:42 +05:30
Andrew Sims
f656fa0f49 add missing copyright headers
Signed-off-by: Andrew Sims <andrew.cameron.sims@gmail.com>
2022-11-23 19:13:43 +11:00
Marek Siarkowicz
2a1055c7f3 raft: Remove dependency on etcd api
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2022-11-08 13:56:46 +01:00
SimFG
5702765729 wal: Fix the walWriteBytes metric
Signed-off-by: SimFG <1142838399@qq.com>
2022-09-22 19:23:06 +08:00
Benjamin Wang
7f10dccbaf Bump go 1.19: update all the dependencies and go.sum files
1. run ./scripts/fix.sh;
2. cd tools/mod; gofmt -w . & go mod tidy;

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-09-22 08:47:46 +08:00
demoManito
72cf0cc04a etcd: modify declaring empty slices
declare an empty slice to var s []int replace  s :=[]int{}, https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices

Signed-off-by: demoManito <1430482733@qq.com>
2022-09-16 14:41:14 +08:00
Vladimir Sokolov
a4f140c9fa testing: fix TestOpenWithMaxIndex cleanup
A WAL object was closed by defer, however the WAL was rewritten afterwards,
so defer closed already closed WAL but not the new one. It caused a data
race between writing file and cleaning up a temporary test directory,
which led to a non-deterministic bug.

Fixes #14332

Signed-off-by: Vladimir Sokolov <vsvastey@gmail.com>
2022-09-07 21:30:16 +03:00
Benjamin Wang
3dd7d3f9af enhance the WAL file related error
The `ErrFileNotFound` was used for for three cases:
1. There is no any WAL files (probably due to no read permission);
2. There is no WAL files matching the snapshot index;
3. The WAL file seqs do not increase continuously.

It's not good for debug when users see the `ErrFileNotFound` error,
so in this PR, a different error is returned for each case above.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-08-03 05:37:30 +08:00
Benjamin Wang
8038e876d3 replace ioutil with os package
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-06-17 10:11:30 +08:00
Benjamin Wang
ccf477d12b restrict the max size of each WAL entry to the remaining size of the file
Currently the max size of each WAL entry is hard coded as 10MB. If users
set a value > 10MB for the flag --max-request-bytes, then etcd may run
into a situation that it successfully processes a big request, but fails
to decode it when replaying the WAL file on startup.

On the other hand, we can't just remove the limitation, because if a
WAL entry is somehow corrupted, and its recByte is a huge value, then
etcd may run out of memory. So the solution is to restrict the max size
of each WAL entry as a dynamic value, which is the remaining size of
the WAL file.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-06-17 05:41:49 +08:00
Marek Siarkowicz
71bba3c761
Merge pull request #14106 from SimFG/remove_case
wal: remove the repeated test case
2022-06-14 12:13:00 +02:00
SimFG
402188a98c wal: remove the repeated test case
The TestFilePipelineFailLockFile case maybe test the line 77 in the alloc function. But the LockFile will not throw an error when the file lock is hold. And TestFilePipelineFailPreallocate and TestFilePipelineFailLockFile are exactly the same except for the comments.

Signed-off-by: SimFG <1142838399@qq.com>
2022-06-14 17:26:20 +08:00
Benjamin Wang
5f8cd5bd39 Replace all etcd versions with the centralized definitions
We have already defined all the constant etcd versions in the
centralized place api/version/version.go. So we should replace all
the versions with the centralized definitions.
2022-06-13 14:08:39 +08:00
Marek Siarkowicz
804fddf921 tests: Use zaptest.NewLogger in tests 2022-04-04 13:03:15 +02:00
Piotr Tabor
f80f477073
Merge pull request #13644 from Juneezee/refactor/t.TempDir
*: use `T.TempDir` to create temporary test directory
2022-02-21 19:52:37 +01:00
AdamKorcz
0fcb2a628c server/storage/wal: fix oss-fuzz issue 44433 2022-02-14 11:50:27 +00:00
Marek Siarkowicz
f4187b4460 tools: Improve proto annotation documentation 2022-01-28 11:40:55 +01:00
Marek Siarkowicz
4bfcd84259 server: Handle V2Request when analysis WAL entries 2022-01-26 15:50:14 +01:00
Marek Siarkowicz
d865bb96f1 server: Refactor wal version to use visitor pattern 2022-01-26 15:50:14 +01:00
Marek Siarkowicz
6d808e5d7d *: Add static validation to etcd_version proto annotation 2022-01-26 15:50:14 +01:00
Eng Zer Jun
e9edc5432c
*: use T.TempDir to create temporary test directory
The directory created by `T.TempDir()` and is automatically removed when
the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-01-25 00:00:46 +08:00
Piotr Tabor
6c2f5dc78a
Merge pull request #13405 from serathius/downgrade-b
Implement single node downgrades
2021-10-29 23:22:10 +02:00
Marek Siarkowicz
431adc5878 server: Implement storage downgrades
By validating if WAL doesn't include any incompatible entries we can
implement storage downgrades.
2021-10-29 12:47:19 +02:00
Marek Siarkowicz
f5d71fa389 server: Detect when WAL includes unapplied cluster version set to higher version
This is because etcd v3.5 will panic when it encounters
ClusterVersionSet entry with version >3.5.0. For downgrades to v3.5 to
work we need to make sure this entry is snapshotted.
2021-10-29 12:47:19 +02:00
Eng Zer Jun
2a151c8982
*: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-28 00:05:28 +08:00
Piotr Tabor
5b226e0abf
Merge pull request #13391 from serathius/downgrade-refactor
Refactor code to make place for downgrade logic
2021-10-08 12:38:25 +02:00
Marek Siarkowicz
703df1c491 server: Move wal versioning functions to wal package 2021-10-08 12:01:53 +02:00
Aleksandr Razumov
3644c9d67b
client/pkg/fileutil: add missing logger to {Create,Touch}DirAll
Also populate it to every invocation.
2021-10-07 17:53:59 +03:00
ben1009
af10e8791f fix typo in wal doc, log:
- fix logs in wal Repair

- unify broken file name to val
2021-08-31 11:59:05 +08:00
Marek Siarkowicz
44b8ae145b etcdserver: Move datadir and wal to storage package 2021-08-03 12:47:37 +02:00