Repository navigation
fix(storage): cancel uploads when source reads fail - #5264
singh4jitendra wants to merge 1 commit into
Conversation
Own a child context for each SDK writer and cancel it when CreateObject returns. Preserve the source error and caller context without closing or publishing a partial upload. Add a regression against the actual SDK writer.
There was a problem hiding this comment.
Code Review
This pull request introduces a cancelable context for object uploads in CreateObject to ensure that abandoned uploads are properly canceled and cleaned up when an error occurs. Additionally, a new unit test TestCreateObjectCancelsUploadAfterSourceError has been added to verify this behavior. I have no feedback to provide as there are no review comments.
|
Hi @charith87, just following up on the failed-upload cleanup fix. Could you help approve the CI runs and take a look when you have a chance? Thanks! |
|
Hi @charith87, could you help approve the pending CI runs and review the upload cleanup fix when you have a chance? Happy to address any feedback. Thanks! |
|
Hi @charith87, could you take a look at the upload cleanup fix when you get a chance? Thanks! |
Description
If
CreateObjectcannot finish reading its input, it returns the source error without closing the SDK writer. The writer can remain active after the call has returned.Give each upload its own context and cancel it when the call exits. This releases the writer on failure without calling
Close, which could finalize partial data. The caller's context and the original source error are preserved.The regression test writes a small partial checkpoint, injects a read error and checks that the actual SDK writer is canceled. This concerns the bucket adapter, not the new unbuffered handler's abort path in #5232.
Link to the issue in case of a bug fix.
Fixes #5259
Testing details
Go 1.27.4, Linux under WSL.
CGO_ENABLED=0and a longer local lint budget:printf 'lint: vet\n\tgolangci-lint run -E=unused --timeout 10m0s --new-from-rev=master\n' | make -f Makefile -f - build- passed with0lint issues. No build checks were skipped.go test -mod=readonly -p 1 -count=1 -timeout=30s -run '^TestCreateObjectCancelsUploadAfterSourceError$' ./internal/storage- failed as expected before the fix because the SDK writer remained active.go test -mod=readonly -p 1 -count=20 -race -timeout=90s -run '^TestCreateObjectCancelsUploadAfterSourceError$' ./internal/storage- passed all 20 repetitions.go test -mod=readonly -p 1 -count=1 -race -timeout=3m -run 'TestCreateObject|TestBucketHandleTestSuite' ./internal/storage- passed on native Linux storage, including the existing bucket-adapter tests.Any backward incompatible change? If so, please explain.
N/A. Successful uploads still close normally. A failed source read cancels only this call's upload and does not finalize partial data or cancel the caller's context.