Repository navigation
fix: make service compaction deterministic and idempotent - #447
Merged
Merged
Conversation
CI commandsComment any of these to rerun checks on this pull request:
The |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #447 +/- ##
==========================================
+ Coverage 84.10% 84.15% +0.05%
==========================================
Files 221 222 +1
Lines 31311 31245 -66
==========================================
- Hits 26333 26294 -39
+ Misses 3736 3718 -18
+ Partials 1242 1233 -9
🚀 New features to boost your workflow:
|
Collaborator
Adversarial review found no issues requiring changes. Verified:
|
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.
Service replicas can have identical confirmed records but different local flush boundaries. Grouping whole source blocks can then produce different
m_<id>.blklayouts, so concurrent compactions can overwrite objects referenced by another attempt's published footer.This change scans and validates the confirmed DataRecord stream and reblocks it deterministically. It ignores source boundaries, counts encoded DataRecord bytes against the configured target, keeps exact fits together, and isolates oversized records in a single block. Output IDs, headers, indexes, and footer bytes are independent of upload scheduling. Uploads remain bounded and parallel; every upload is drained on failure/cancellation, and the footer is published only after all uploads succeed. Memory admission now accounts for the source buffer, bounded uploads, and the output builder.
Repeated compaction of an already-Sealed segment succeeds. A metadata revision conflict is treated as idempotent only after a refresh confirms that another attempt sealed the same LAC; different ranges, truncation, deletion, refresh failures, and unrelated errors remain visible.
Fixes #446.
Compatibility and rollout
Regression coverage
TestStagedStorageService_ConcurrentAuditorsCompactionto the existing E2E Service failover selection. Two real writer/auditor instances survive takeover and automatically compact the same segment through real gRPC services, etcd and MinIO. Stopped replicas are reblocked into 1, 8 and 24 local blocks and restarted. Cover a real same-LAC etcd CAS conflict and a full auditor pass failing after successful server execution because all three RPC responses are lost. Verify both auditors keep cycling, SDK reads remain complete, and the new writer can append/read the next segment. No manualSegmentHandle.Compactcalls drive this E2E.Validation
go test -race ./tests/integration -run '^TestStagedStorageService_ConcurrentAuditorsCompaction$' -count=3 -timeout=7m -vgo test -race ./server/storage/stagedstorage ./server/storage/objectstorage ./woodpecker/segment ./server/processor -count=1 -timeout=5mSelected integration tests against external MinIO and etcd, with
-race:TestCompactionMemoryEstimate_HoldsAgainstARealCompaction,TestStagedFileWriter_CompactOperation,TestStagedFileReader_ReadLocalAndCompacted, andTestDataCorruptionService_Active_TwoReplicasTruncated.The real compaction memory test measured a 16,797,992-byte reservation and 22,991,512-byte sampled heap growth (1.37x, within its 4x regression bound).
golangci-lint run --config .golangci.yml --timeout=5m ./server/storage/stagedstorage/... ./server/storage/... ./woodpecker/segment/...git diff --check