Skip to content

Fix incorrect early termination in descending scan of unpackOneFakeMemChunkMetaData#17283

Open
shuwenwei wants to merge 1 commit intomasterfrom
fixDescSerisScanBug0311
Open

Fix incorrect early termination in descending scan of unpackOneFakeMemChunkMetaData#17283
shuwenwei wants to merge 1 commit intomasterfrom
fixDescSerisScanBug0311

Conversation

@shuwenwei
Copy link
Member

Description

Problem

In the streaming query path of MemChunkLoader, unpackOneFakeMemChunkMetaData iterates through statisticsList to construct LazyMemVersionPageReader instances.

However, the original implementation always iterated statisticsList in ascending order while using the following early termination logic:

(orderUtils.getAscending() && orderTime > satisfiedTimeRange.getMax())
|| (!orderUtils.getAscending() && orderTime < satisfiedTimeRange.getMin())

When executing a descending scan, statisticsList is still ordered from small to large timestamps. This may cause the loop to break prematurely because the first element already satisfies orderTime < satisfiedTimeRange.getMin(), even though later elements could still fall within the query time range.

As a result, some valid pages may not be added to the page reader list, leading to missing data during descending scans.

Solution

This PR fixes the issue by iterating statisticsList according to the scan order:
• Ascending scan: iterate statisticsList in its natural order.
• Descending scan: iterate statisticsList in reverse order.

With this change, the early termination condition (break) becomes correct for both scan directions because the iteration order now matches the scan order.

The behavior is now consistent with the logic used in unpackOneChunkMetaData, where pageReaderList is also traversed differently depending on the scan order.

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 0% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.70%. Comparing base (ea3cc3c) to head (b8dad72).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...gine/execution/operator/source/SeriesScanUtil.java 0.00% 24 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17283      +/-   ##
============================================
- Coverage     39.71%   39.70%   -0.01%     
  Complexity      282      282              
============================================
  Files          5100     5100              
  Lines        341950   341977      +27     
  Branches      43559    43562       +3     
============================================
- Hits         135798   135796       -2     
- Misses       206152   206181      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shuwenwei shuwenwei requested a review from JackieTien97 March 12, 2026 01:59
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.

1 participant