Repository navigation
feat(streamingwrites): abort parallel uploads on unlink, destroy and upload failure - #5232
PranjalC100 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements the Abort method for the GCS Writer interface and integrates it into the unbufferedWriteHandlerImpl to support Destroy and Unlink operations. Specifically, it introduces an Abort method to discard unfinalized uploads, updates the fake and mock writers to support this behavior, and ensures that subsequent operations (such as writes, syncs, flushes, and truncates) are safely ignored or handled after an unlink. Extensive unit tests have been added to verify these abort, unlink, and destroy flows. No review comments were provided, and the implementation is clean and well-tested.
e1b4254 to
bf1a9a4
Compare
076427f to
e1b0ce9
Compare
…upload failure Implement Unlink and Destroy in the unbuffered write handler, and abort the upload when it fails. - Add Abort to gcs.Writer, and AbortUpload to gcs.Bucket as the counterpart of FinalizeUpload. monitoringBucket records it as gcs_method "AbortUpload", throttledBucket doesn't throttle it, and the other wrappers pass it through. - Unlink marks the handler unlinked and aborts the upload. After that, writes and truncates are discarded and Sync and Flush do nothing, without an error and without touching the writer, so the deleted object isn't created. - An upload failure records the sticky error and then aborts the upload. - Destroy aborts an upload that hasn't been finalized. - Abort runs at most once, before the writer context is canceled, in a write.streaming.upload.abort span. - WriteHandler.Unlink and Destroy, Inode.Unlink, FileHandle.Destroy and FileInode.DeRegisterFileHandle take the FUSE operation's context, so the abort's metrics and span are linked to that operation. cloud.google.com/go/storage v1.70.0 doesn't implement Writer.Abort yet, so the abort error is logged and canceling the writer context is the only cleanup for now.
- Drop blockSize from the unbuffered write handler and pass 0 as the chunk size, which parallel uploads don't use (TODO b/581184469). - Tests: drop a redundant AssertNotCalled, use setup ops and literal offsets in the after-unlink test, add errAbortFailure, cover Destroy after an upload failure, and finalize after the abort in the prefix-bucket test. - Comments: drop the repeated ctx sentences and claims that aren't true yet.
e1b0ce9 to
1c0926b
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #5232 +/- ##
==========================================
+ Coverage 85.19% 85.32% +0.12%
==========================================
Files 181 182 +1
Lines 19957 20054 +97
==========================================
+ Hits 17003 17111 +108
+ Misses 2953 2942 -11
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Replace the one-off abort tests with tables: AbortsUpload, AbortErrorIsReturnedOnlyByDestroy and DoesNotAbortWithoutActiveUpload. - Cover truncates and a pending forward truncate after unlink, the fake writer after Abort, the context FileInode passes to the handler, and the SDK's unsupported Abort error in bucketHandle. - Point the Writer.Abort TODO at b/540721232, and add TODOs for aborting staged parallel uploads (b/581184469) and the fake writer's context (b/584925513).
- Split AbortErrorIsReturnedOnlyByDestroy into DestroyReturnsAbortError and UploadFailureDoesNotReturnAbortError, which checks that a failed write or finalize doesn't return the abort error. - Comments: Flush marks the writer closed, uploadError is returned until Unlink, and throttledBucket never delays or blocks the abort.
|
Hi @vadlakondaswetha, @vipnydav, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you! |
| // and Sync and Flush do nothing, without touching the writer, so that the | ||
| // deleted object isn't created. They return no error, even after an upload | ||
| // failure, so that applications holding the file open can finish cleanly. | ||
| unlinked bool |
There was a problem hiding this comment.
@vadlakondaswetha WDYT about keeping unlinked here vs. checking f.IsUnlinked() in file.go?
Today fs.go / file.go already skip FlushFile, SyncFile, and SetMtime when f.IsUnlinked(), so unlinked is only needed here because FileInode still forwards Write and Truncate to streamingWriteHandler after Unlink. (BufferedWriteHandler didn't track unlinked and instead suppressed context.Canceled in uploadBlock.)
Are we fine keeping unlinked in unbufferedWriteHandlerImpl or should we check f.IsUnlinked() in FileInode's streaming-write helpers so neither handler gets called after Unlink?
The only downside I see is that fstat after unlink and writes would return pre unlinked sizes.
There was a problem hiding this comment.
@PranjalC100 If we decide to keep the unlinked here, we should update totalSize / truncatedSize in Write and Truncate when wh.unlinked is true so WriteFileInfo().TotalSize (fstat(fd)) stays accurate, matching bwh.
There was a problem hiding this comment.
Kept unlinked. After Unlink, Write/Truncate now update totalSize/truncatedSize like bwh, so fstat stays accurate. A FileInode check would hide them from both handlers, so fstat would show the pre-unlink size.
- Flush and abort set the writer to nil, and abort returns early when there's no writer, replacing the writerClosed flag. - Remove the SDK TODO from abort and the "counterpart of FinalizeUpload" sentence from gcs.Bucket.AbortUpload.
- Reword the Abort and AbortUpload docs: they cancel the parallel upload, release its buffers and abort the upload session on GCS, so uploaded parts are discarded. The dummy IO bucket uses the same wording. - Drop the comment on aborting before the writer context is canceled and the UnsupportedBySDK test case, and fix the abort test comment: the abort's trace span nests under the operation's span.
After Unlink, Write and Truncate update totalSize and truncatedSize without touching the writer, so fstat keeps reporting the size the application wrote, as with the buffered write handler.
- After Unlink, every truncate sets the size, so the totalSize comment is exact. Test a truncate that was pending when the file was unlinked. - Drop a Sync assertion that can't fail, rename a duplicate writeErr in the unlink test, and reword the uploadError comment.
vipnydav
left a comment
There was a problem hiding this comment.
LGTM. We can merge once we align on whether we want to keep the unlinked variable in uwh or not.
Description
Second and last part of the unbuffered write handler, after #5215. It implements
UnlinkandDestroy, and aborts the upload on failure (design: go/gcsfuse-grpc-parallel-upload-v1-integration, "Unlink & Abort Cleanup" and "Observability & Debuggability").gcs.WritergetsAbort(), andgcs.BucketgetsAbortUpload(ctx, writer), which discards the parts uploaded so far.throttledBucketdoesn't throttle it, the other wrappers and the mocks pass it through, and the fake marks the writer aborted so later writes and finalizes fail.Unlinkmarks the handler unlinked and aborts the upload. After that, writes and truncates only update the size thatfstatreports, andSync/Flushdo nothing, without an error and without touching the writer, so the deleted object isn't created.handleUploadFailurerecords the sticky error, then aborts the upload.Destroyaborts an upload that hasn't been finalized.abortruns at most once, before the writer context is canceled.monitoringBucketrecordsAbortUploadingcs/request_countandgcs/request_latenciesasgcs_method="AbortUpload"(added tometrics.yaml, generated code updated).write.streaming.upload.abortspan, documented indocs/tracing.md.WriteHandler.Unlink/Destroy,Inode.Unlink,FileHandle.DestroyandFileInode.DeRegisterFileHandletake the FUSE operation's context, so the abort span nests underfs.unlink/fs.file.release_handle.blockSizeand passes 0 as the chunk size, which parallel uploads don't use. bucketHandle will set their part size from its write config (b/581184469).cloud.google.com/go/storagev1.70.0 doesn't implementWriter.Abortyet (b/540721232 tracks the SDK release with parallel uploads), so for now the error is logged and the writer context is canceled.Link to the issue in case of a bug fix.
b/581184283
Testing details
AbortUpload, before the writer context is canceled, on the operation's context), a failing abort, unlink and destroy without an active upload, operations after unlink and the size they report, the fake writer afterAbort, the contextFileInodepasses to the handler, andAbortUploadinbucketHandle, the prefix bucket and the stat-cache bucket.make buildpasses, andgo test -racepasses for the changed packages.Any backward incompatible change? If so, please explain.
No. Only internal interfaces change.