Skip to content

fix: preserve same-transaction changes when moving a sub-bucket - #1239

Open
Spider2298 wants to merge 1 commit into
etcd-io:mainfrom
Spider2298:fix-movebucket-same-tx-data-loss
Open

fix: preserve same-transaction changes when moving a sub-bucket#1239
Spider2298 wants to merge 1 commit into
etcd-io:mainfrom
Spider2298:fix-movebucket-same-tx-data-loss

Conversation

@Spider2298

Copy link
Copy Markdown

MoveBucket silently drops changes made to a sub-bucket in the same transaction as the move. In the worst case, a bucket that is created, populated, and moved within a single transaction ends up empty after commit, with no error.

The moved sub-bucket is removed from the source bucket's in-memory cache, and its current on-disk header is written under the destination. But a sub-bucket materialized earlier in the transaction keeps its pending changes in that cached in-memory bucket, which is only spilled at commit while walking the parent's cache. Dropped from the source and never added to the destination, it is never spilled, so the changes are lost. The existing tests don't catch this because they always populate the source in one transaction and move it in another.

This carries the materialized sub-bucket over to the destination's cache so its pending changes (including those of nested sub-buckets) are spilled correctly. Adds TestTx_MoveBucket_PendingChanges covering a modify-then-move and a create-populate-move within a single transaction; both fail without the fix.

Authored with help from Claude.

A sub-bucket modified in the same transaction as a MoveBucket had its
pending changes dropped, because the materialized bucket was removed from
the source cache and never spilled under the destination.

Signed-off-by: Michael Ellis <anz5michael@gmail.com>
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Spider2298
Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant