Skip to content

fix(fs): silence missing-upload noise and lock #1083 race - #1667

Open
overtrue wants to merge 1 commit into
mainfrom
p8/1083-concurrent-complete-put-regression
Open

overtrue wants to merge 1 commit into
mainfrom
p8/1083-concurrent-complete-put-regression

Conversation

@overtrue

Copy link
Copy Markdown
Collaborator

Summary

Attributes and locks down the intermittent aws-sdk-java-v2 S3Client.putObject versions:S3Exception/500/- failure tracked in #1083, and fixes the false-positive fs_storage_error diagnostic observed in the first post-#1666 e2e-mint run (46083521885).

Root Cause & Attribution (reproduced on c93c7940)

  • In the pinned Mint suite (minio/mint@12559d50), S3TestUtils.uploadMultipartObjectAsync (S3TestUtils.java:126) calls s3AsyncClient.completeMultipartUpload(completeMultipartUploadRequest) without .get() or .join(). Immediately afterward, uploadObjectVersions_test (S3Client.putObject versions) sends three PutObject overwrites to the same unversioned (bucketName, "testobject") while the 50 MiB background CompleteMultipartUpload is still executing.
  • Between feat(fs): replay a repeated CompleteMultipartUpload as RustFS does #1053 (1fa1c4af, 2026-09-29 — one day before the first occurrence on 314233c8) and feat(fs): coordinate shared-root version mutations and null recovery #1660 (7ee712e3, 2026-11-27), CompleteMultipartUpload released version_lock after publish_object_if, deleted the 50 MiB .complete-* tombstone directory, and then ran completion_replay::record_completion(&published.directory, ...) outside version_lock.
  • When a concurrent PutObject superseded that null version during the tombstone-removal window, remove_null_versions (remove_dir_all) unlinked body and record while record_completion created completion inside the same v-* directory. rmdir failed with ENOTEMPTY (500 InternalError) and left an orphaned v-* directory containing only ["completion"] with no record, causing every subsequent AWS SDK v2 retry to fail permanently with 500 InternalError.
  • Reproduced directly on detached c93c7940 in 16 iterations (v-00000000000000001482-... -> files ["completion"], PutObject -> 500 InternalError, retry PutObject -> 500 InternalError).
  • feat(fs): coordinate shared-root version mutations and null recovery #1660 (7ee712e3) structurally eliminated the race by staging completion inside .tmp-* before atomic rename (write_staged_completion_receipt) and holding version_lock through remove_dir_all(&tombstone). Post-feat(fs): coordinate shared-root version mutations and null recovery #1660/feat(mint): capture closed-vocabulary server 5xx diagnostics #1666 e2e-mint.yml run 46083521885 on main (6c1c8299) passed aws-sdk-java-v2 7 PASS / 0 FAIL / 0 NA with zero HTTP 5xx responses across all 15 SDKs.

Changes in this PR

  • crates/fs/src/versioning/tests.rs: add n_complete_multipart_stages_receipt_and_blocks_put_until_tombstone_removed to deterministically assert that completion is staged inside the published version directory before tombstone cleanup/lock release, that a concurrent PutObject waits while version_lock is held across tombstone cleanup, and that the superseded version and .complete-* tombstone are removed cleanly with no orphan v-*/completion directory.
  • crates/fs/tests/crud/multipart_replay.rs: add n_unawaited_multipart_completion_racing_put_and_get_never_returns_500 exercising unawaited signed CompleteMultipartUpload racing concurrent signed PutObject and GetObject calls on the same unversioned key.
  • crates/fs/src/uploads.rs + crates/fs/tests/crud/storage_error_observer.rs: short-circuit io::ErrorKind::NotFound in FsBackend::read_upload_record before calling decode_upload_record so expected 404 NoSuchUpload lookups (observed as fs_storage_error crates/fs/src/uploads.rs:568 (x2) in run 46083521885) no longer trigger the process-wide storage_error observer.
  • s3s check: does not apply to s3s (rustfs-gateway-fs is this repository's local filesystem reference backend and diagnostic observer).

Closes #1083

Verification

$ cargo fmt --all --check
# exited 0

$ cargo clippy --workspace --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.62s

$ cargo test --workspace
# all workspace unit, integration, and doc tests passed (exit 0)

$ cargo xtask verify --crate rustfs-gateway-fs
verify: crate rustfs-gateway-fs build compiled 2 crate(s) in 7.74s outside the budget
verify: crate rustfs-gateway-fs passed in 25.02s

$ bash scripts/check_file_size.sh && bash scripts/check_license_headers.sh && bash scripts/check_test_target_coverage.sh && bash scripts/check_no_planning_docs.sh && bash scripts/check_layer_dependencies.sh
OK: max 6114 lines, 15 allowance(s) used
test-target coverage: 22 workspace members, 12 consolidated to 15 target(s), 4 excepted at 5 target(s), 20 linked by cargo test --workspace

Mutation Proofs

  1. Commented out write_staged_completion_receipt in crates/fs/src/versioning/publish.rs -> n_complete_multipart_stages_receipt_and_blocks_put_until_tombstone_removed failed (completion receipt must be staged before atomic rename and lock release).
  2. Dropped guard before complete_remove / tombstone removal in crates/fs/src/completion.rs -> n_complete_multipart_stages_receipt_and_blocks_put_until_tombstone_removed failed (PutObject must wait while CompleteMultipartUpload still holds version_lock during tombstone cleanup).
  3. Removed remove_safe_dir(&self.tombstone) in TombstoneState::Remove in crates/fs/src/staging.rs -> n_complete_multipart_stages_receipt_and_blocks_put_until_tombstone_removed failed (tombstone leaked: [".complete-..."]).
  4. Disabled std::fs::remove_dir_all(path) in crates/fs/src/versioning/null_recovery.rs::remove_version_dir_strict -> n_unawaited_multipart_completion_racing_put_and_get_never_returns_500 failed (assertion left == right failed: iter 0: expected a single healthy null version directory, left: 5, right: 1).
  5. TDD red-first before the NotFound short-circuit in crates/fs/src/uploads.rs::read_upload_record -> storage_error_observer::set_storage_error_observer_installs_once_and_fires_only_on_failure failed (healthy operations must not notify storage_error observer).

Role Verdicts

  • simplicity-adversary: attacked the missing-upload NotFound short-circuit, lock-held receipt staging invariants, and concurrent test cost against the 30s crate budget — no break found.

Breaking Change

  • BREAKING — this PR touches a protected file or changes a public contract.

Checklist

  • The four-command gate passed (fmt, clippy, test, cargo xtask verify)
  • New or changed public API has rustdoc
  • Negative test cases outnumber positive ones
  • Every new assertion was mutated — the implementation was broken on purpose and the assertion
    went red. The PR description names which ones
  • No Protected File touched; if one was, the PR description contains BREAKING and a migration path
  • No unsafe introduced
  • No inventory / linkme introduced
  • No #[non_exhaustive] added to a DTO
  • No s3s code copied; behavioural evidence is URL + self-written summary
  • No credentials, signatures, or expected-signature values reachable from logs or error bodies
  • No plan document, analysis report, or working note committed
  • Commits follow Conventional Commits; PR title ≤72 characters
  • A Handoff comment has been appended to the issue

Attribute and lock down the intermittent aws-sdk-java-v2
`S3Client.putObject versions:S3Exception/500/-` failure (#1083)
and eliminate false-positive `fs_storage_error` noise observed during the
first post-#1666 e2e-mint run (46083521885):

- Root cause (reproduced on c93c794): Mint's `uploadMultiPartAsync_test`
  (`S3TestUtils.java:126`) invokes `s3AsyncClient.completeMultipartUpload`
  without awaiting its `CompletableFuture`, immediately followed by
  `uploadObjectVersions_test` issuing three `PutObject` calls to the same
  unversioned `(bucketName, "testobject")`. Before #1660 (`7ee712e3`),
  `CompleteMultipartUpload` released `version_lock`, removed the 50 MiB
  tombstone directory, and then wrote `v-*/completion` outside the lock.
  When a concurrent `PutObject` ran `remove_null_versions` (`remove_dir_all`)
  on that same version directory, `record_completion` created `completion`
  mid-removal, failing `rmdir` with `ENOTEMPTY` (`500 InternalError`) and
  leaving an orphaned `v-*` directory containing only `["completion"]`
  (with `record` already unlinked), causing every AWS SDK v2 retry to fail
  permanently with `500 InternalError`.
- #1660 (`7ee712e3`) structurally eliminated this race by staging the
  `completion` receipt inside `.tmp-*` before atomic rename and holding
  `version_lock` through tombstone removal. Post-#1660/#1666 Mint run
  46083521885 passed `aws-sdk-java-v2` 7 PASS / 0 FAIL with zero HTTP 5xx
  responses across all 15 SDKs.
- Regression tests: add a deterministic lock-and-staging invariant test
  (`versioning::tests::n_complete_multipart_stages_receipt_and_blocks_put_until_tombstone_removed`)
  and a live signed `S3Service` concurrent completion-vs-PUT/GET test
  (`multipart_replay::n_unawaited_multipart_completion_racing_put_and_get_never_returns_500`).
- Diagnostic hygiene: short-circuit `io::ErrorKind::NotFound` in
  `FsBackend::read_upload_record` before calling `decode_upload_record` so
  expected `404 NoSuchUpload` lookups no longer fire the process-wide
  `storage_error` observer (`crates/fs/src/uploads.rs:568`), verified by
  `storage_error_observer::isolated_child_probe`.

Closes #1083
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci(mint): attribute intermittent aws-sdk-java-v2 putObject failure

1 participant