Fix cursor automatically moving to next position when delete and put are in the same TXN by ahrtr · Pull Request #611 · etcd-io/bbolt

@ahrtr

…n one txn

Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>

fuweid

tjungblu

tjungblu

@ahrtr

…tem from a node

Refer to boltdb/bolt#357

Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>

@ahrtr ahrtr mentioned this pull request

Nov 17, 2023

@ahrtr ahrtr marked this pull request as draft

December 6, 2023 09:55

jsternberg added a commit to jsternberg/buildkit that referenced this pull request

Jan 30, 2025
The `emptyBranchWithParents` method could accidentally leave link
entries that shouldn't exist. When finding these links, deleting during
the iteration can sometimes cause the cursor to jump entries that should
be deleted.

This changes the code path to delete the links outside of the iteration
to avoid this.

This is caused by a long-standing bug in bolt that can't be fixed
easily. See etcd-io/bbolt#611 for details.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>

jsternberg added a commit to jsternberg/buildkit that referenced this pull request

Jan 30, 2025
The `emptyBranchWithParents` method could accidentally leave link
entries that shouldn't exist. When finding these links, deleting during
the iteration can sometimes cause the cursor to jump entries that should
be deleted.

This changes the code path to delete the links outside of the iteration
to avoid this.

This is caused by a long-standing bug in bolt that can't be fixed
easily. See etcd-io/bbolt#611 for details.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>

otoolep added a commit to rqlite/rqlite that referenced this pull request

Sep 9, 2025
Collect and delete keys that are less than or equal to the requested index. 

Removing key/values pairs in a bucket during iteration on the bucket using cursor may not work properly. Each time when removing a key/value pair, the cursor may automatically move to the next position if present. When users call c.Next() after removing a key, it may skip one key/value pair. Refer to etcd-io/bbolt#611 for more detailed info.