Repository navigation
fix(storage): list s3 before hasura when looking for orphans - #5267
Merged
dbarrosop merged 3 commits intoOct 29, 2026
Merged
Conversation
dbarrosop
approved these changes
Oct 28, 2026
Review issue: PR_5267/RUN-16792637555358421441/WU-001 / finding 001 — .nhost-code/review/PR_5267_COMMENT_001.md — ADDRESSED, ACCEPT Resolution: - Shared orphan listing performs expected O(n+m) ID comparison with one metadata-indexing pass and one S3 pass, benefiting both list and delete endpoints. - Membership still uses each object's basename while results preserve original S3 keys and listing order. - Expanded existing endpoint tests exercise pending metadata, reordered and duplicate inputs, and empty/all-matched results. Why: - The existing controller owns this comparison; a local set removes repeated scanning without a helper, interface change, dependency, or altered external call contract. - Using the same set idiom as listBrokenMetadata keeps the two reconciliation paths consistent. Decisions: - Accept O(m) additional memory for metadata IDs in exchange for expected linear comparison CPU; continue iterating S3 rather than the map to retain observable ordering and duplicate occurrences. Review-plan variance: - The suggested plan's optional BenchmarkListOrphans was not added; the reviewer verified linear scaling out of tree instead (40k files in about 5 ms versus about 32 s measured in the finding). Checks: - `nix develop '.#storage' -c golines -l --base-formatter=gofumpt .` — exit 0: passed; reviewed state unchanged. - `nix develop '.#storage' -c golangci-lint run --timeout 600s ./...` — exit 0: passed; reviewed state unchanged. - `nix develop '.#storage' -c go test -count=1 -race ./services/storage/controller/...` — exit 0: passed; reviewed state unchanged.
Review issue: PR_5267/RUN-16792637555358421441/WU-002 / finding 002 — .nhost-code/review/PR_5267_COMMENT_002.md — ADDRESSED, ACCEPT Resolution: - Re-check UUID candidates with admin metadata access immediately before deletion. Skip existing rows, proceed only on ErrFileNotFound, fail closed on other lookup errors, and report only deleted keys. Non-UUID garbage remains directly deletable. - Convert nullable metadata scalar fields safely so pending uploads no longer panic; populated values and existing pointer/map semantics remain unchanged. - Add stateful re-upload tests, nullable-conversion cases, and an HTTP fixture exercising the real Hasura adapter while cleanup skips a pending row and continues to later orphans. Why: - Snapshot membership can become stale before deletion. Any metadata row must protect its content because InitializeFile precedes PutFile. - Pending rows have NULL etag until PopulateMetadata; the new lookup must decode them without aborting cleanup. Decisions: - Use the operator-selected bounded re-check, not atomic coordination. An upload starting after the absence check can still race with DeleteObject; this residual risk is accepted and documented in the code and Storage README. - Nullable fields map to zero values required by the existing API. All GetFileByID consumers now handle pending rows: normal read paths return their existing not-uploaded error, while ReplaceFile can proceed as designed. Review-plan variance: - Include the supporting metadata conversion fix and regression tests now, as explicitly approved after review reproduced the NULL-etag panic. Checks: - `nix develop '.#storage' -c golines -l --base-formatter=gofumpt .` — exit 0: passed; reviewed state unchanged. - `nix develop '.#storage' -c golangci-lint run --timeout 600s ./...` — exit 0: passed; reviewed state unchanged. - `nix develop '.#storage' -c go test -count=1 -race ./services/storage/controller/... ./services/storage/metadata/...` — exit 0: passed; reviewed state unchanged. - `git diff --cached --check b94e02c` — exit 0: passed; reviewed state unchanged. Validation limit: - Live Hasura integration suite unavailable; real-adapter HTTP fixture and controller/metadata race suites passed.
dbarrosop
force-pushed
the
storage-orphans-list-s3-first
branch
from
October 29, 2026 09:00
5302898 to
bc17ad1
Compare
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uploads create the metadata row before writing the object to S3.
listOrphanslisted Hasura first and S3 second, so a file uploaded between the two calls was in S3 but not in the Hasura list, and delete-orphans removed it. Listing S3 first means every object in that list already has its row.The new test simulates an upload landing between the two listings.
Fixes #5186
Checklist