Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20210429 etcdctl v2 backup cindex fix #12906

Merged
merged 5 commits into from
Apr 29, 2021

Conversation

ptabor
Copy link
Contributor

@ptabor ptabor commented Apr 28, 2021

Fix ETCDCTL_API=2 etcdctl backup --with-v3 consistent index consistency

Prior to this CL, ETCDCTL_API=2 etcdctl backup --with-v3 was readacting WAL log
(by removal of some entries), but was NOT updating consistent_index in the backend.
Also the WAL editing logic was buggy, as it didn't took in consideration the fact
that when TERM changes, there can be entries with duplicated indexes in
the log. So its NOT sufficient to subtract number of removed entries to
get accurate log indexes.

The PR replaces removing and shifting of WAL entries with replacing them with an no-op entries.
Thanks to this consistent-index references are staying up to date.

The PR also:

  • updates 'verification' logic to check whether consistent_index does not lag befor last snapshot
  • env-gated execution of verification framework in etcdctl backup.

Tested with:

(./build.sh && cd tests && EXPECT_DEBUG=TRUE 'env' 'go' 'test' '-timeout=300m' 'go.etcd.io/etcd/tests/v3/e2e' -run=TestCtlV2Backup --count=1000 2>&1 | tee TestCtlV2BackupV3.log)

@ptabor ptabor force-pushed the 20210429-etcdctl-v2-backup-cindex-fix branch from 79ffd9f to 7fae99c Compare April 28, 2021 21:26

consistentIndexKeyName = []byte("consistent_index")
ConsistentIndexKeyName = []byte("consistent_index")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use case for making this public? If we need, can we document this saying this belongs to meta bucket?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to get rid of duplicated independent constants. In particular this one is used in: server/mvcc/kvstore.go for list of ignored keys when 'hash' is being computed, so no easy way to merge it into cindex package.

Parted port of my PR to this one, to make it consistent: 9fb0aa3

@ptabor ptabor requested review from gyuho and jingyih April 29, 2021 07:41
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2021

Codecov Report

Merging #12906 (e90504f) into master (ed4a87d) will increase coverage by 4.71%.
The diff coverage is 63.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12906      +/-   ##
==========================================
+ Coverage   66.48%   71.19%   +4.71%     
==========================================
  Files         426      430       +4     
  Lines       33965    34082     +117     
==========================================
+ Hits        22581    24266    +1685     
+ Misses       9316     7834    -1482     
+ Partials     2068     1982      -86     
Flag Coverage Δ
all 71.19% <63.15%> (+4.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/expect/expect.go 80.55% <0.00%> (-3.74%) ⬇️
server/embed/etcd.go 76.44% <0.00%> (+2.78%) ⬆️
server/mvcc/util.go 0.00% <ø> (ø)
server/verify/verify.go 49.01% <50.00%> (-2.99%) ⬇️
etcdctl/ctlv2/command/backup_command.go 71.91% <54.34%> (-0.35%) ⬇️
server/etcdserver/cindex/cindex.go 81.57% <75.00%> (-10.43%) ⬇️
etcdctl/ctlv3/command/migrate_command.go 61.53% <100.00%> (ø)
server/etcdserver/server.go 79.19% <100.00%> (+4.13%) ⬆️
server/mvcc/kvstore.go 85.52% <100.00%> (+1.68%) ⬆️
...ver/proxy/grpcproxy/adapter/lock_client_adapter.go 0.00% <0.00%> (-100.00%) ⬇️
... and 166 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed4a87d...e90504f. Read the comment docs.

…ency

Prior to this CL, `ETCDCTL_API=2 etcdctl backup --with-v3` was readacting WAL log
(by removal of some entries), but was NOT updating consistent_index in the backend.
Also the WAL editing logic was buggy, as it didn't took in consideration the fact
that when TERM changes, there can be entries with duplicated indexes in
the log. So its NOT sufficient to subtract number of removed entries to
get accurate log indexes.

The PR replaces removing and shifting of WAL entries with replacing them with an no-op entries.
Thanks to this consistent-index references are staying up to date.

The PR also:
  - updates 'verification' logic to check whether consistent_index does not lag befor last snapshot
  - env-gated execution of verification framework in `etcdctl backup`.

Tested with:
```
(./build.sh && cd tests && EXPECT_DEBUG=TRUE 'env' 'go' 'test' '-timeout=300m' 'go.etcd.io/etcd/tests/v3/e2e' -run=TestCtlV2Backup --count=1000 2>&1 | tee TestCtlV2BackupV3.log)
```
In case of failed verification, the server used to keep opened backend
(so the file was locked on OS level).
@ptabor ptabor force-pushed the 20210429-etcdctl-v2-backup-cindex-fix branch from 9fb0aa3 to e90504f Compare April 29, 2021 09:51
Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thx!

@ptabor ptabor merged commit 835643e into etcd-io:master Apr 29, 2021
@ptabor ptabor deleted the 20210429-etcdctl-v2-backup-cindex-fix branch April 29, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants