Repository navigation
[Bug] Fix SeriesScanUtil/AlignedSeriesScanUtil correctness bugs and remove dead streamingQueryMemChunk config - #19444
Closed
JackieTien97 wants to merge 2 commits into
Closed
JackieTien97 wants to merge 2 commits into
JackieTien97 wants to merge 2 commits into
Conversation
Cover SeriesScanUtil and AlignedSeriesScanUtil with a differential test harness in the test sources of datanode: - SeriesScanUtilFuzzTest generates scenarios (closed and open files, flushed chunks, memory tables, deletions, time and value filters, limit and offset, ascending and descending) and checks three ways of scanning against a brute-force oracle. - SeriesScanUtilDefectTest pins twelve defects with minimal scenarios and asserts the correct result, so its tests fail until each defect is fixed. - SeriesScanKnownIssues keeps the randomized test green by leaving out the scenarios that hit a known defect; scan_strict=1 runs them all the same. No production code is changed.
…streamingQueryMemChunk Fixes apache#19443 - Apply value-column deletions in AlignedTVListIterator point-read paths and OrderedMultiAlignedTVListIterator (and reset delete cursors on reset / DESC scans). - Advance the file unpack horizon in SeriesScanUtil when leading metadata yields no chunks so overlapping seq/unseq chunks are not skipped by OFFSET/LIMIT or double-counted by aggregation statistics. - Stop trusting queryAllSensors as timeAllSelected in AlignedSeriesScanUtil for tree-model wildcard OFFSET/LIMIT pushdown. - Decode modified AbstractAlignedPageReader pages with deletions applied before evaluating pushDownFilter and pagination in SeriesScanUtil.nextPage(). - Gate COUNT_TIME statistics via canUseCurrent*TimeStatistics() and exact single-non-null aligned time statistics without regressing value-only aggregation statistics; propagate modified flags for deleted value columns and dropped value pages in ModificationUtils, DiskAlignedChunkMetadataLoader, and DiskAlignedChunkLoader. - Remove immutable IoTDBConfig.streamingQueryMemChunk and dead non-streaming branches in ResourceByPathUtils, MemChunkLoader, MemAlignedChunkLoader, and SeriesScanUtil. - Remove unreachable D2/D6/D8 defect UTs, fix queried-column deletion projection in SeriesScanMaterializer, and add end-to-end IoTDBSeriesScanDefectIT covering all 8 bugs.
Contributor
Author
|
Closing to reopen from an apache/iotdb branch so SonarCloud checks can run. |
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.
Description
Fixes #19443
How the Bugs Were Located
SeriesScanUtilFuzzTest): We built an oracle-checked differential test harness drivingSeriesScanUtilandAlignedSeriesScanUtilacross three data models (non-aligned, aligned tree, aligned table), ascending/descending scans, closed and open files (flushed chunks + memtables), file/memtable deletions, time/value filters,LIMIT/OFFSET, and three scan drivers (SeriesScanOperatorstyle, explicit file→chunk→page statistics audit, andSeriesAggregationScanOperatorstyle).IoTDBSeriesScanDefectIT): From 12 minimal UT failures surfaced by the fuzzer, we audited each candidate against production code paths:SimpleIT) and 1C3D (ClusterIT) before applying fixes (11/11 IT cases failing on baseline).TsFileProcessor.asyncFlush()has 0 callers insrc/mainsinceDirectFlushPolicyunconditionally closes the processor).IoTDBConfig.streamingQueryMemChunkis hardcodedtruewith no config key or production setter).IoTDBConfig.streamingQueryMemChunkfield/getters/setters and simplified the unreachable non-streaming branches accordingly; removed the 3 unreachable defect UTs.Root Causes & Solutions (with Examples)
1. Flushing aligned memtable value-column deletions ignored on point-read and multi-TVList paths
d1(s0, s1)with closed seq file(2, 200, 99)and flushing unseq memtable(1, 10, 1), (2, 20, 2)(or two non-overlapping sorted TVLists in a flushing memtable). AfterDELETE FROM root.db.d1.s0 WHERE time >= 1 AND time <= 2(recorded inmodsToMemtable),SELECT s0, s1 FROM root.db.d1 WHERE time <= 2:s0values (1 -> (10, 1),2 -> (20, 2)).1 -> (null, 1),2 -> (null, 2).AlignedTVListIterator.nextTimeValuePair()/currentTimeValuePair()read raw values without checkingvalueColumnsDeletionList, andAlignedTVListIterator.reset()/ batchDESCscans did not reset delete cursors properly.OrderedMultiAlignedTVListIterator.currentIteratorIndex(int)ignored the per-column deletionbitMap.AlignedTVList(track per-column deletion flags inprepareNext(), apply them innextTimeValuePair()/currentTimeValuePair(), properly initialize/reset delete cursors forASC/DESC) andOrderedMultiAlignedTVListIterator(return-1whenbitMap.isMarked(columnIndex)).2. Stale file-unpack horizon after a fully-deleted leading seq file breaks
OFFSET/LIMITpushdown and aggregation statisticsd1.s0with seq File A(1, 1), (2, 2)(fully deleted via mods; kept alive by siblings1), unseq File U(2, 20), (3, 30), and seq File B(3, 3), (4, 4):SELECT s0 FROM root.db.d1 LIMIT 2 OFFSET 2: Before returned3 -> 3, 4 -> 4; After returns4 -> 4.SELECT COUNT(s0), SUM(s0) FROM root.db.d1: Before returned4, 57.0; After returns3, 54.0.SeriesScanUtil.initFirstChunkMetadata()unpacked overlapped files only up to the firstTimeSeriesMetadata's endpoint (2). When File A yielded zero chunks, File U's chunk (ending at3) becamefirstChunkMetadatawithout advancing the unpack horizon to3, leaving File B unpacked and undetected as overlapping.SeriesScanUtil: stabilize the unpack horizon in a loop whenever unpacked metadata/chunks extend past the previous horizon before filtering or returningfirstChunkMetadata.3. Wildcard
SELECT *OFFSET/LIMITover-consumes offset on all-null rows in tree modeld1(s0, s1), page 1(1, 1, null), (2, null, 2), (3, 3, null), page 2(4, 4, null), (5, 5, null), afterDELETE FROM root.db.d1.s1 WHERE time >= 1 AND time <= 5.SELECT * FROM root.db.d1 LIMIT 5 OFFSET 3:2), returning4 -> (4, null), 5 -> (5, null).5 -> (5, null).AlignedSeriesScanUtil.timeAllSelected()returnedtruewheneverqueryAllSensorswas set, ignoring dropped/deleted columns. Removed thequeryAllSensorsshortcut inAlignedSeriesScanUtil.timeAllSelected(IMetadata)so it always delegates tometadata.timeAllSelected()under tree mode (ignoreAllNullRows == true).4. Value-filter pushdown returns rows deleted to
nullon modified aligned pagesd1(s0, s1)with(1, 10, 1), (2, 20, 2), (3, 30, 3), afterDELETE FROM root.db.d1.s0 WHERE time = 2.SELECT s0, s1 FROM root.db.d1 WHERE s0 != 173:1 -> (10, 1), 2 -> (null, 2), 3 -> (30, 3).1 -> (10, 1), 3 -> (30, 3).AbstractAlignedPageReaderevaluatespushDownFilter.allSatisfy(...)against pre-deletion statistics (min=10, max=30), bypassing row-level filtering for values turnednullby mods.SeriesScanUtil.nextPage(): for modifiedAbstractAlignedPageReaderwith apushDownFilter, decode the page with deletions applied first and then applypushDownFilterand pagination viaTsBlockUtil.applyFilterAndLimitOffsetToTsBlock(...). (An upstream fix in Apache TsFile can complement this.)5.
COUNT_TIME(*)over-counts dropped/all-null rows on aligned tree devices (subset/dropped columns, full-column deletion, dropped value pages)SELECT COUNT_TIME(*) FROM root.db.d1):(1, 1, null), (2, null, 2), (3, 3, null)+DELETE TIMESERIES root.db.d1.s1(and 3-column variant droppings2): Before3→ After2.DELETE FROM root.db.d1.s1 WHERE time >= 1 AND time <= 3: Before3→ After2.(1, null, 1), (2, 2, null), (3, 3, null), Page 2(4, 4, null)+DELETE FROM root.db.d1.* WHERE time = 1: Before4→ After3.COUNT(s0),SUM(s1)) can still safely use value statistics on sparse aligned files (preservingAlignedSeriesScanPredicatePushDownTestand avoiding performance regression), whereasCOUNT_TIME(*)(valueColumnIndex == -1) relies on time-column statistics that include all-null rows.canUseCurrent{File,Chunk,Page}TimeStatistics()onSeriesScanUtil/AlignedSeriesScanUtiland routed time-statistics aggregators (TreeAggregator.usesTimeStatistics()) through them inAbstractSeriesAggregationScanOperator. When at most one queried measurement is non-null in tree mode,AlignedSeriesScanUtil.current*TimeStatistics()returns that column's exact statistics; when multiple sparse columns exist withouttimeAllSelected,COUNT_TIME(*)falls back to row-level scanning.modifiedflags inModificationUtils/DiskAlignedChunkMetadataLoaderwhen a value column's chunk metadata is deleted tonull, and inDiskAlignedChunkLoaderwhen deletions overlap a page's time range or drop an entire value page. Also overrodegetMeasurementCount()inAlignedPageMetadataandMemAlignedPageReader.6. Dead
IoTDBConfig.streamingQueryMemChunkcleanupIoTDBConfig.streamingQueryMemChunk(isStreamingQueryMemChunk/setStreamingQueryMemChunk) and simplified the always-streaming branches inResourceByPathUtils,MemChunkLoader,MemAlignedChunkLoader,ReadOnlyMemChunk,AlignedReadOnlyMemChunk, andSeriesScanUtil.Verification
IoTDBSeriesScanDefectIT):SimpleIT(1C1D) 11/11 FAIL,ClusterIT(1C3D) 11/11 FAIL.SimpleIT(1C1D) 11/11 PASS,ClusterIT(1C3D) 11/11 PASS.SimpleIT1C1D +ClusterIT1C3D):IoTDBCountTimeAlignedDeviceIT(7/7),IoTDBCountTimeIT(6/6),IoTDBAlignedDataDeletionIT(12/12),IoTDBAlignedSeriesQueryWithDeletionIT(3/3) — all PASS.SeriesScanUtilDefectTest: 9/9 PASS.SeriesScanUtilFuzzTest: default (360 scenarios, 0 skipped) PASS; strict full-dimension (scan_strict=1 scan_scenarios=200 scan_flushed=1 scan_subset=1, 1,200 scenarios, 0 skipped) PASS.AlignedSeriesScanPredicatePushDownTest,MemChunkLoaderTest,MemAlignedChunkLoaderTest,AlignedMemPageReaderTest,AlignedPriorityMergeReaderTest, etc.) — all PASS.mvn spotless:apply,python3 .github/scripts/check-it-selection.py, and bothen&-P with-zh-localebuilds PASS.This PR has:
Key changed/added classes in this PR
AlignedTVList,OrderedMultiAlignedTVListIteratorSeriesScanUtil,AlignedSeriesScanUtilTreeAggregator,AbstractSeriesAggregationScanOperatorModificationUtils,DiskAlignedChunkMetadataLoader,DiskAlignedChunkLoader,AlignedPageMetadata,MemAlignedPageReaderIoTDBConfig,ResourceByPathUtils,MemChunkLoader,MemAlignedChunkLoader,ReadOnlyMemChunk,AlignedReadOnlyMemChunkIoTDBSeriesScanDefectITandscanfuzz/*test suite