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

Improve snapshot status #15979

Merged
merged 1 commit into from
Jun 15, 2024
Merged

Improve snapshot status #15979

merged 1 commit into from
Jun 15, 2024

Conversation

cenkalti
Copy link
Member

Adding unmarshaling for items in "key" bucket for extra safety.

Copy link

@lavacat lavacat left a comment

Choose a reason for hiding this comment

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

Overall lgtm, but needs a test

etcdutl/snapshot/util.go Outdated Show resolved Hide resolved
etcdutl/snapshot/util.go Outdated Show resolved Hide resolved
@cenkalti cenkalti force-pushed the snapshot-status branch 2 times, most recently from d634c55 to de8c7aa Compare May 30, 2023 19:14
@cenkalti
Copy link
Member Author

@lavacat I added a test. Can you take a look again please?

@cenkalti
Copy link
Member Author

cenkalti commented Jun 8, 2023

/cc: @chaochn47

@chaochn47
Copy link
Member

chaochn47 commented Jun 8, 2023

If the CI is green, I think this should attract more reviewers to take a look and approve the PR.

You can git commit --amend --no-edit and force pushed it to restart the test for now :\

I've tried in #15659 but with no luck.

Copy link
Member

@jmhbnz jmhbnz left a comment

Choose a reason for hiding this comment

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

Hey @cenkalti - It looks like a minor update to fix the static analysis see below.

Can you also please rebase this pr.

etcdutl/snapshot/v3_snapshot_test.go Show resolved Hide resolved
@ahrtr
Copy link
Member

ahrtr commented Jan 18, 2024

I recall we refactored the bytesToRev in another PR, please try to reuse the existing function. thx

@cenkalti
Copy link
Member Author

Sure, I'll rebase this PR and make sure all checks pass.

@cenkalti cenkalti force-pushed the snapshot-status branch 2 times, most recently from 32f60ef to 3b4dfb6 Compare January 19, 2024 00:50
@cenkalti
Copy link
Member Author

/retest

@cenkalti cenkalti force-pushed the snapshot-status branch 5 times, most recently from 7f32b22 to 91cc26d Compare January 19, 2024 06:32
sub := int64(binary.BigEndian.Uint64(bytes[9:]))
if main < -1 || sub < 0 { // finishedCompactRev can be -1
return BucketKey{}, errors.New("negative revision")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Revision numbers must be positive. Negative values are invalid. I added these extra checks to be able to detect corruptions on database when checking snapshot status on disk.

Copy link
Member

Choose a reason for hiding this comment

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

Suggest not to change the signature. Instead we can add assertion (panicking when it breaks any invariant properties)

Copy link
Member

Choose a reason for hiding this comment

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

Also I see your comment "// finishedCompactRev can be -1". Can you elaborate in what exact case finishedCompactRev may be -1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any case etcd may persist the -1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted back the signature change. Now it's panicking in case of invalid revision bytes.

@cenkalti
Copy link
Member Author

/retest

@cenkalti
Copy link
Member Author

All tests passing. Ready for review again.

@cenkalti
Copy link
Member Author

@ahrtr I squashed all my commits.

// TestSnapshotStatus is the happy case.
// It inserts pre-defined number of keys and asserts the output hash of status command.
// The expected hash value must not be changed.
// If it changes, there must be some backwards incompatible change introduced.
Copy link
Member

@serathius serathius Jan 26, 2024

Choose a reason for hiding this comment

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

Could we merge the tests before we change logic? It's nice to separate the refactors and tests that are meant to prove nothing changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's necessary because refactors doesn't affect the hash value in any way. They're only about adding extra error conditions.

@cenkalti cenkalti force-pushed the snapshot-status branch 2 times, most recently from 574fb2a to 447c25e Compare January 26, 2024 15:39
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

lgtm

Thanks

etcdutl/snapshot/v3_snapshot.go Outdated Show resolved Hide resolved
etcdutl/snapshot/v3_snapshot.go Show resolved Hide resolved
etcdutl/snapshot/v3_snapshot.go Outdated Show resolved Hide resolved
etcdutl/snapshot/v3_snapshot_test.go Outdated Show resolved Hide resolved
@cenkalti cenkalti force-pushed the snapshot-status branch 2 times, most recently from 2513bd2 to 7ef0a43 Compare January 26, 2024 16:13
@jmhbnz
Copy link
Member

jmhbnz commented Mar 28, 2024

Discussed during sig-etcd triage meeting, it looks like this older pr was very close to merge, @cenkalti could you please rebase to address conflicts?

@cenkalti
Copy link
Member Author

I'll do it this weekend.

@cenkalti
Copy link
Member Author

Rebased. Ready to merge.

@jmhbnz
Copy link
Member

jmhbnz commented Jun 6, 2024

Hi @cenkalti can you please rebase this? Thanks

@jmhbnz
Copy link
Member

jmhbnz commented Jun 8, 2024

/retest

@ivanvc
Copy link
Member

ivanvc commented Jun 13, 2024

This PR was very close to merging. It has been rebased a couple of times. Does it make sense to move forward? There is at least an open comment from @fuweid: https://github.com/etcd-io/etcd/pull/15979/files#r1467819098.

We have several reviewers but only approval from @ahrtr.

What would be required to move forward with this pull request?

@fuweid
Copy link
Member

fuweid commented Jun 13, 2024

There is at least an open comment from @fuweid: https://github.com/etcd-io/etcd/pull/15979/files#r1467819098.

It's just my two cents for using %w. In the whole project, it's using : %w.
If err= prefix is easy for grep in command line, it's fine.

Signed-off-by: Cenk Alti <cenkalti@gmail.com>
@cenkalti
Copy link
Member Author

I fixed the error messages and rebased again.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 68.57143% with 11 lines in your changes missing coverage. Please review.

Project coverage is 68.85%. Comparing base (15f9a59) to head (23c4428).

Current head 23c4428 differs from pull request most recent head ea46253

Please upload reports for the commit ea46253 to get more accurate results.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
Files Coverage Δ
server/storage/mvcc/revision.go 91.48% <80.00%> (-3.39%) ⬇️
etcdutl/snapshot/v3_snapshot.go 57.43% <64.00%> (+8.53%) ⬆️

... and 25 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #15979      +/-   ##
==========================================
+ Coverage   68.75%   68.85%   +0.10%     
==========================================
  Files         416      416              
  Lines       35128    35151      +23     
==========================================
+ Hits        24152    24203      +51     
+ Misses       9569     9542      -27     
+ Partials     1407     1406       -1     

Continue to review full report in Codecov by Sentry.

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

Copy link
Member

@jmhbnz jmhbnz left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks @cenkalti

@jmhbnz jmhbnz merged commit debc8fb into etcd-io:main Jun 15, 2024
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet