Repository navigation
fix(storage): preserve source generation checks during atomic rename - #5239
singh4jitendra wants to merge 1 commit into
Conversation
Send source generation and metageneration in the same Move conditions so a stale rename cannot move a replacement object. Add HTTP request regressions and keep zero-generation behavior unchanged.
There was a problem hiding this comment.
Code Review
This pull request updates the MoveObject operation in internal/storage/bucket_handle.go to correctly apply source preconditions (GenerationMatch and MetagenerationMatch) using storage.Conditions instead of directly setting the generation on the object handle. It also updates the documentation comments in internal/storage/gcs/request.go to clarify this behavior and adds comprehensive unit tests in internal/storage/bucket_handle_test.go to verify that source preconditions are correctly sent and handled. There are no review comments to address, and the changes look solid.
|
Hi @meet2mky, could you review this rename fix when you get a chance? Let me know if there's anything you'd like changed. Thanks! |
|
Hi @meet2mky, could you finish the review when you get a chance and merge if all looks good? Thanks! |
|
Hi @meet2mky, could you take a look at the source-generation check for rename when you get a chance? The regression test is in, and I'd be happy to make any changes needed. Thanks! |
|
Hi @meet2mky, I'd appreciate your review of the rename generation-check fix when you have a moment. Happy to make any adjustments needed. Thanks! |
|
Hi @meet2mky, could you review the rename generation-check fix when you get a chance? Thanks! |
Description
A rename should fail if another writer has replaced the source file. The SDK's Move call was not sending the generation selected on the source handle, so checking metageneration alone could miss that replacement.
This sends both source conditions together. The tests capture the actual HTTP request and cover a replacement with the same metageneration.
Link to the issue in case of a bug fix.
Fixes #5236
Testing details
Go 1.27.2, Ubuntu 24.04 under WSL.
make build- passed, including vet, lint (0 issues), formatting and compilation.go test -mod=readonly -p 1 -count=1 -timeout=90s -run '^TestMoveObject(SourcePreconditions|RejectsReplacedSource)$' ./internal/storage- failed as expected before the fix.go test -mod=readonly -p 1 -count=1 -race -timeout=90s -run '^TestMoveObject(SourcePreconditions|RejectsReplacedSource)$' ./internal/storage- passed after the fix.go test -mod=readonly -p 1 -count=1 -race -timeout=5m ./internal/storage ./internal/fs/inode- passed.Any backward incompatible change? If so, please explain.
A stale rename now returns the existing precondition error instead of moving a replacement file. A zero source generation still means the latest object without a generation condition. Destination behavior is unchanged.