fix(s3, azure): stream writes instead of buffering the body #27
No reviewers
Labels
No labels
area/client
area/revisions
bug
clarity/ambiguous
clarity/clear
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
size/L
size/M
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
basepeak-ai/workspace-provider!27
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/stream-s3-azure-writes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of basepeak-ai/bpai#1220. Every hosted tenant uses the S3 backend, and it read each written file whole into memory before uploading it.
What
S3 (
pkg/client/s3.go):feature/s3/managerwith 8 MiB parts and 2 in flight, about 32 MiB per write including that first chunk, instead of the file's size.Azure (
pkg/client/azure.go):UploadStreamwith 8 MiB blocks and 2 in flight, about 16 MiB per write. Before, the body went throughio.ReadAllfirst.A body that fails part-way is never stored on either backend. The S3 multipart upload is aborted, and the Azure block list is never committed.
Not in this PR
Reordering the revision bookkeeping, so that a failed write leaves revision state unchanged, was taken out after review. Doing it after the upload widens the window in which two writers with the same
latestRevisionIDboth succeed, and makes a failed revision-info write unsafe to retry. It will come as its own PR, with a per-file lock and retry-safe commits.Checks
go vet ./...: clean.golangci-lint(after a cache clean): 0 issues.go mod tidy: no diff.go test -count=1 -race ./...without credentials, against the directory backend and an in-process fake S3: all pass.dxflrs/garage:v2.1.0, path-style, the SaaS backend) and Azurite: 217 passed, 0 skipped, no objects left behind.What the tests cover:
s3.gothis test reads 8.5 MB;Not run: S3 virtual-hosted style, MinIO, real Azure.
Shipping
The providers image clones this repo's
mainwhen it is built (bpai-tools/scripts/package-providers.sh), so this ships with the next bpai-tools tag after merge.111ed92e1696d31bce6afix(s3, azure): stream writes, and keep revisions intact on failureto fix(s3, azure): stream writes instead of buffering the bodyReview (two fresh-context reviewers): outcome
Fixed (
96d31bc): every streamed S3 write used to allocate a full 8 MiB part buffer, even for tiny files: ~8.5 MB for a 2 KB write. A body that fits in one part is now sent as a plain PutObject. There is a test for that, plus tests at the exactly-part-size and part-size+1 boundaries, and for a reader that fails inside the first part.Split out: the revision reordering (formerly
111ed92). Review found it made two concurrent writers with the samelatestRevisionIDboth succeed, and one write could be lost with no conflict (verified; main returns a conflict). It also made a failed revision-info write unsafe to retry, and a cancel after commit could delete the only copy of the old content. That work needs a per-file lock and retry-safe commits, so it becomes a follow-up PR.Confirmed safe:
Pre-existing, noted for the revisions follow-up:
N+1survivesDeleteFileand stays readable throughGetRevision(erasure);createRevision=falseskips thelatestRevisionIDcheck entirely;