Skip to content

Fix flaky PARTIAL/FINAL plan assertion in rateFunctionsNormalTest - #18556

Merged
JackieTien97 merged 1 commit into
masterfrom
fix-flaky-rate-intermediate-agg-it
Aug 31, 2026
Merged

Fix flaky PARTIAL/FINAL plan assertion in rateFunctionsNormalTest#18556
JackieTien97 merged 1 commit into
masterfrom
fix-flaky-rate-intermediate-agg-it

Conversation

@JackieTien97

Copy link
Copy Markdown
Contributor

Description

IoTDBTableAggregation2IT.rateFunctionsNormalTest (inherited from IoTDBTableAggregationIT) fails sporadically:

Expected a PARTIAL aggregation in plan: { ... "Step": "SINGLE" ... "RegionId": "3", "DeviceNumber": "8" ... }

Root cause

assertRateQueryUsesIntermediateAggregation unconditionally requires the EXPLAIN (FORMAT JSON) output of an ungrouped rate()/increase()/irate()/delta() query over rate_merge_test to contain a PARTIAL/FINAL two-step aggregation. That split only exists when the scanned data spans more than one DataRegion.

IoTDBTableAggregation2IT runs with data_partition_allocation_strategy = SHUFFLE. PartitionBalancer.shuffleAllocationStrategy assigns each (seriesSlot, timeSlot) to a random DataRegionGroup, and all 8 rows of rate_merge_test fall into one time partition. So occasionally all 8 devices land in the same DataRegion; the planner then correctly produces a SINGLE-step aggregation with one DeviceTableScanNode, and the assertion fails even though both the plan and the query result are correct (the result comparison right before the assertion had already passed).

Fix

Count the distinct RegionId values in the JSON plan first. Skip the PARTIAL/FINAL check when the plan scans fewer than two distinct regions (a SINGLE aggregation is the correct plan there), and keep asserting it whenever the data actually spans multiple regions — which preserves the original intent of the check in the deterministic base-class environment (CUSTOM extension policy with 2 DataRegions per DataNode).

Verification

  • IoTDBTableAggregationIT#rateFunctionsNormalTest and IoTDBTableAggregation2IT#rateFunctionsNormalTest pass locally (TableSimpleIT).
  • The region-count regex was verified against the single-region failing plan shape (count 1 → skip), a multi-region shape (count 2 → assert), and "RegionId": "Not Assigned" (count 0 → skip).

🤖 Generated with Claude Code

assertRateQueryUsesIntermediateAggregation unconditionally required a
PARTIAL/FINAL aggregation split in the EXPLAIN output. Under randomized
data partition allocation (the SHUFFLE strategy used by
IoTDBTableAggregation2IT), all 8 devices of rate_merge_test may
occasionally land in a single DataRegion, where a SINGLE-step
aggregation is the correct plan, so the assertion failed sporadically.

Skip the PARTIAL/FINAL check when the plan scans fewer than two
distinct RegionIds; keep it whenever the data actually spans regions.
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.33%. Comparing base (7a38e7e) to head (1e54da9).

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18556      +/-   ##
============================================
- Coverage     42.34%   42.33%   -0.01%     
  Complexity      413      413              
============================================
  Files          5411     5411              
  Lines        390231   390231              
  Branches      51071    51071              
============================================
- Hits         165233   165221      -12     
- Misses       224998   225010      +12     

☔ View full report in Codecov by Harness.
📢 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.

@JackieTien97
JackieTien97 merged commit e096f63 into master Aug 31, 2026
39 of 40 checks passed
@JackieTien97
JackieTien97 deleted the fix-flaky-rate-intermediate-agg-it branch September 1, 2026 01:39
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