← Back to Pull requests

objectfs: fix data corruption after truncates and run multi-seed fsx #171

Closed
unknown closed this pull request without merging on Oct 04, 2026 20:21 UTC
View on GitHub
unknown unknown commented on Oct 04, 2026 17:39 UTC
Author

Summary

This PR addresses the intermittent fsx data corruption issues where plain reads returned incorrect/zeroed bytes following truncates and unaligned writes.

Root Causes & Fixes

1. FUSE Client Partial Chunk Handling:
- In ObjectFS.Write, previously only writes with non-zero chunk offsets (offset % cs != 0) checked if the chunk was present in cache. Writes starting at chunk boundaries with length smaller than chunk size, or writes spanning across chunk boundaries whose end chunk was not fully overwritten, did not load existing data from the controller when the chunk was absent from local cache. WriteAt subsequently allocated empty zero-filled buffers, erasing existing content outside the written span.
- Updated ObjectFS.Write to check all chunks spanned by the write and load any non-fully overwritten chunk from the controller if not present in NodeCache.

2. FUSE NodeCache Chunk / Data Discrepancy & Invalidation:
- In NodeCache, GetRange previously checked len(entry.Data) > 0 and returned zeros for offsets beyond len(entry.Data), bypassing cached chunks in entry.Chunks.
- Updated NodeCache so entry.Chunks is the single authoritative store for range queries, and Put slices data into entry.Chunks.
- After a successful TruncateFile RPC in ObjectFS.SetAttr, marked the cache entry clean (fs.cache.MarkClean).

3. Controller Inode Upload & Chunk Loading Synchronization:
- Replaced WaitGroup-based inode upload tracking in Volume with condition-variable reference counted tracking to safely coordinate concurrent writes, truncates, and reads on the same inode without race conditions or premature deletions.
- Added upload synchronization to Volume.WriteFile to ensure blob uploads from earlier writes complete before subsequent writes read or overwrite chunk contents.
- Added ChunksLoaded tracking to CachedInode to guarantee that all FileChunk rows are loaded from the metadata store before updating chunks in Volume.WriteFile.

4. POSIX Gate Multi-Seed fsx & Artifact Collection:
- Updated dev/ci/presubmits/ap-posix to run fsx across 5 seeds (42, 1337, 2026, 777, 9999) with 1000 ops each.
- Copied failure artifacts (.fsxops, .fsxgood) to $ARTIFACTS. (Note: when ap generate in gke-labs/gke-labs-infra is updated, the ap-posix workflow job can upload $ARTIFACTS as well).

Testing


  • Added TestFUSETruncateAndUnalignedWriteWithCacheInvalidation in pkg/objectfs/fuse/fuse_test.go.

  • Added TestTruncateAndWriteOrderingWithDelayedUploads in pkg/objectfs/controller/service_test.go.

  • Ran all 5 seeds of fsx (1000 ops each) and pjdfstest in ap-posix in Docker; all passed cleanly.

  • All presubmit checks (ap-lint, ap-build, ap-test, ap-posix) pass.
  • Fixes #170

    Diff: 353 lines (+264 / -89) across 4 files Reviewer: justinsb Review duration: 161m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 353 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.351
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #171"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%