Fix Non-Deterministic Behavior in NewReadChunkCompactionPerformerWithAlignedSeriesTest #16884
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.
Fix Non-Deterministic Behavior in NewReadChunkCompactionPerformerWithAlignedSeriesTest
Problem
Thirteen tests in
NewReadChunkCompactionPerformerWithAlignedSeriesTestwere failing non-deterministically under NonDex due to order-dependent measurement schema comparisons:testCompactionWithAllDeletiontestCompactionWithDeletiontestCompactionWithDeletionAndEmptyPagetestCompactionWithPartialDeletiontestCompactionWithPartialDeletionAndEmptyPagetestSimpleCompactiontestSimpleCompactionByFlushChunktestSimpleCompactionWithEmptyChunktestSimpleCompactionWithEmptyPagetestSimpleCompactionWithNullValuetestSimpleCompactionWithNullValueAndEmptyChunktestSimpleCompactionWithNullValueAndEmptyPagetestSimpleCompactionWithSomeDeviceNotInTargetFileWay to Reproduce
Root Cause
The
CompactionCheckerUtils.getAllPathsOfResources()method usedHashSetfor storing paths and did not sort measurement schemas before constructingAlignedFullPathobjects:The
schemaMapis backed byConcurrentHashMapwhich has non-deterministic iteration order. When NonDex shuffled collection order, measurements appeared in different positions withinAlignedFullPath, causing data comparison assertions to fail even though the compaction results were semantically correct.Solution
Made measurement ordering deterministic by sorting schemas and using ordered collections.
Changes Made
Before (Order-Dependent):
After (Order-Independent):
Key Improvements
HashSettoLinkedHashSetto preserve insertion order for deterministic iterationComparator.comparing()AlignedFullPathobjects always have measurements in consistent alphabetical orderjava.util.ComparatorimportVerification
mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex \ -Dtest=NewReadChunkCompactionPerformerWithAlignedSeriesTest \ -DnondexRuns=3 -Drat.skip=true # Result: All 15 tests pass across 3 different random seeds (933178, 974622, 1016066)Key Changed Classes
getAllPathsOfResources()method (~10 lines), test utility changes only