Skip to content

cache: migrate storage layer to B-tree#20507

Merged
serathius merged 1 commit intoetcd-io:mainfrom
apullo777:store-btree
Aug 26, 2025
Merged

cache: migrate storage layer to B-tree#20507
serathius merged 1 commit intoetcd-io:mainfrom
apullo777:store-btree

Conversation

@apullo777
Copy link
Copy Markdown
Contributor

@k8s-ci-robot
Copy link
Copy Markdown

Hi @apullo777. 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.

Details

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
Copy link
Copy Markdown
Member

/ok-to-test

Comment thread cache/store.go

func newStore() *store {
return &store{kvs: make(map[string]*mvccpb.KeyValue)}
func newStore(degree int) *store {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have enough tests for store to replace implementation now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will write some unit tests for store!

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.14%. Comparing base (aa9e9df) to head (857b36c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

see 84 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #20507      +/-   ##
==========================================
+ Coverage   64.86%   69.14%   +4.27%     
==========================================
  Files         420      420              
  Lines       34776    34776              
==========================================
+ Hits        22559    24045    +1486     
+ Misses      10818     9331    -1487     
- Partials     1399     1400       +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 aa9e9df...857b36c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread cache/store_test.go Outdated
Comment on lines +183 to +211
name: "apply_with_same_revision_multiple_events",
initialKVs: []*mvccpb.KeyValue{makeKV("/a", "oldA", 10), makeKV("/b", "oldB", 10)},
initialRev: 10,
eventBatches: [][]*clientv3.Event{
{makePutEvent("/a", "newA", 10), makePutEvent("/b", "newB", 10)},
},
expectedLatestRev: 10,
expectedSnapshot: []*mvccpb.KeyValue{makeKV("/a", "newA", 10), makeKV("/b", "newB", 10)},
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note, events with single revision should be applied at once, within single lock, same like etcd. If not, cache will expose partially applied revision which is invalid. So this test case is incorrect, also please make sure we correctly apply revision. We could add validation in storage that prevents same revision being applied twice to prevent this kind of bug.

Comment thread cache/store_test.go
clientv3 "go.etcd.io/etcd/client/v3"
)

func TestStoreGet(t *testing.T) {
Copy link
Copy Markdown
Member

@serathius serathius Aug 19, 2025

Choose a reason for hiding this comment

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

Thanks for extensive tests, however I would recommend to send them in separate PR that we merge first. This way we know that both previous and the current implementation passes them.

Comment thread cache/store_test.go Outdated
expectedSnapshot: nil,
},
{
name: "delete_nonexistent",
Copy link
Copy Markdown
Member

@serathius serathius Aug 19, 2025

Choose a reason for hiding this comment

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

This is sign of potential inconsistency, we should consider rejecting such write and purging cache. This is however something for a followup.

Signed-off-by: Peter Chang <peter.yaochen.chang@gmail.com>
@k8s-ci-robot
Copy link
Copy Markdown

k8s-ci-robot commented Aug 25, 2025

@apullo777: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-integration-4-cpu-arm64 857b36c link true /test pull-etcd-integration-4-cpu-arm64

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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. I understand the commands that are listed here.

@k8s-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apullo777, serathius

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@serathius serathius merged commit afaa220 into etcd-io:main Aug 26, 2025
30 of 31 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.

3 participants