etcd
etcd copied to clipboard
etcdserver: separate maybeCompactRaftLog function to compact raft log independently
Part of #17098
Goal: separate maybeCompactRaftLog function to compact raft log independently from snapshots.
TODO
- [x] Add tests for the changes
- [x] https://github.com/etcd-io/etcd/issues/17098#issuecomment-2374327464
- [ ] https://github.com/etcd-io/etcd/pull/18637
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: clement2026 Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Hi @clement2026. Thanks for your PR.
I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
@serathius Please take a look. This PR focuses on one task only.
Codecov Report
:x: Patch coverage is 76.66667% with 7 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 68.88%. Comparing base (59cfd7a) to head (841da6e).
:warning: Report is 2079 commits behind head on main.
:warning: Current head 841da6e differs from pull request most recent head f34bee5
Please upload reports for the commit f34bee5 to get more accurate results.
Additional details and impacted files
| Files with missing lines | Coverage Δ | |
|---|---|---|
| server/storage/wal/repair.go | 56.14% <100.00%> (ø) |
|
| server/storage/wal/file_pipeline.go | 90.69% <0.00%> (ø) |
|
| server/etcdserver/server.go | 81.03% <85.71%> (-0.31%) |
:arrow_down: |
| server/storage/wal/wal.go | 57.73% <71.42%> (+0.27%) |
:arrow_up: |
... and 13 files with indirect coverage changes
@@ Coverage Diff @@
## main #18635 +/- ##
==========================================
+ Coverage 68.79% 68.88% +0.08%
==========================================
Files 420 420
Lines 35522 35545 +23
==========================================
+ Hits 24438 24485 +47
+ Misses 9657 9639 -18
+ Partials 1427 1421 -6
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 59cfd7a...f34bee5. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
I can't test ep.compacti directly because it's not accessible. However, I checked the logs and confirmed it’s working as expected.
Add log statements
ep := etcdProgress{
confState: sn.Metadata.ConfState,
snapi: sn.Metadata.Index,
appliedt: sn.Metadata.Term,
appliedi: sn.Metadata.Index,
compacti: fi - 1,
}
s.Logger().Info("initial ep.compacti", zap.Uint64("ep.compacti", ep.compacti),zap.Uint64("ep.snapi", ep.snapi))
compacti := ep.snapi - s.Cfg.SnapshotCatchUpEntries
if compacti <= ep.compacti {
return
}
s.Logger().Info("compacti > ep.compacti", zap.Uint64("compacti", compacti), zap.Uint64("ep.compacti", ep.compacti))
Start a new etcd instance and make 110 put requests
➜ rm -rf default.etcd; bin/etcd --experimental-snapshot-catchup-entries=5 --snapshot-count=10 2>&1 | grep 'ep.compacti'
➜ benchmark put --key-space-size=9999999 --val-size=100 --total=110
Logs:
{"level":"info","ts":"2024-09-24T23:38:10.660332+0800","caller":"etcdserver/server.go:823","msg":"initial ep.compacti","ep.compacti":0,"ep.snapi":0}
{"level":"info","ts":"2024-09-24T23:38:16.890460+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":6,"ep.compacti":0}
{"level":"info","ts":"2024-09-24T23:38:16.959513+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":17,"ep.compacti":6}
{"level":"info","ts":"2024-09-24T23:38:17.017577+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":28,"ep.compacti":17}
{"level":"info","ts":"2024-09-24T23:38:17.096548+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":39,"ep.compacti":28}
{"level":"info","ts":"2024-09-24T23:38:17.159693+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":50,"ep.compacti":39}
{"level":"info","ts":"2024-09-24T23:38:17.238754+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":61,"ep.compacti":50}
{"level":"info","ts":"2024-09-24T23:38:17.316651+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":72,"ep.compacti":61}
{"level":"info","ts":"2024-09-24T23:38:17.391588+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":83,"ep.compacti":72}
{"level":"info","ts":"2024-09-24T23:38:17.460776+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":94,"ep.compacti":83}
{"level":"info","ts":"2024-09-24T23:38:17.539552+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":105,"ep.compacti":94}
^C
Restart the etcd instance and make 50 put requests
➜ bin/etcd --experimental-snapshot-catchup-entries=5 --snapshot-count=10 2>&1 | grep 'ep.compacti'
➜ benchmark put --key-space-size=9999999 --val-size=100 --total=50
Logs:
{"level":"info","ts":"2024-09-24T23:38:24.076007+0800","caller":"etcdserver/server.go:823","msg":"initial ep.compacti","ep.compacti":110,"ep.snapi":110}
{"level":"info","ts":"2024-09-24T23:39:16.807112+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":116,"ep.compacti":110}
{"level":"info","ts":"2024-09-24T23:39:16.880017+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":127,"ep.compacti":116}
{"level":"info","ts":"2024-09-24T23:39:16.941133+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":138,"ep.compacti":127}
{"level":"info","ts":"2024-09-24T23:39:17.012076+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":149,"ep.compacti":138}
{"level":"info","ts":"2024-09-24T23:39:17.075207+0800","caller":"etcdserver/server.go:2195","msg":"compacti > ep.compacti","compacti":160,"ep.compacti":149}
PR needs rebase.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.