Skip to content

Fix pattern_match partition isolation and singleton handling - #18924

Merged
JackieTien97 merged 2 commits into
masterfrom
codex/fix-pattern-match-partition-state
Oct 20, 2026
Merged

JackieTien97 merged 2 commits into
masterfrom
codex/fix-pattern-match-partition-state

Conversation

@JackieTien97

@JackieTien97 JackieTien97 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix two partition-boundary defects in pattern_match:

  • Partition processors shared one QetchAlgorithm. With two partitions of five rows each, the second emitted pass-through indexes 5..9 against a five-row cache and failed with Invalid position 5 and length 1 in block with 5 positions.
  • A singleton partition had no curve section, but finalization dereferenced that missing section and threw NullPointerException.

Create and configure a fresh algorithm for each processor. Finish inputs that have not formed a section without producing matches. Ordinary and regex regression tests cover successive partitions, independently interleaved processors, and singleton partitions before, between, and after matching partitions.

Validation

  • The three isolation regressions fail before the isolation fix. Both new singleton regressions reproduce the null-pointer failure before the boundary fix.
  • Clean reactor verification with TableSimpleIT: all 5 unit tests and both SQL integration tests passed in a 1 ConfigNode / 1 DataNode environment.
  • Clean reactor test of node-commons and its dependencies with with-zh-locale: all 5 unit tests passed.
  • Spotless, Checkstyle, and license checks passed in the isolated verification checkout.
mvn clean verify -pl integration-test -am -P with-integration-tests,TableSimpleIT \
  -Dtest=PatternMatchTableFunctionTest \
  '-Dit.test=IoTDBWindowTVFIT#testPatternMatchPartitions+testPatternMatchRegexPartitions' \
  -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false \
  -Dfailsafe.failIfNoSpecifiedTests=false

mvn clean test -pl iotdb-core/node-commons -am -P with-zh-locale \
  -Dtest=PatternMatchTableFunctionTest \
  -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false

This PR has:

  • been self-reviewed.
  • added comments explaining the intent of the changes.
  • added unit tests.
  • added integration tests.
  • been tested in a test IoTDB cluster.

@JackieTien97 JackieTien97 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the singleton-partition failure described inline and add regression coverage. This is a pre-existing defect reproduced with both the base and PR implementations; the current partition-state isolation tests pass clean verification.


private void assertPartitionStateIsIsolated(String pattern) {
TableFunctionProcessorProvider provider = createProvider(pattern);
double[][] partitions = {{1, 2, 3, 2, 1}, {10, 20, 30, 20, 10}, {2, 3, 2, 1}};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle singleton partitions without throwing. The partition fixtures here all contain at least four rows, so they miss a real boundary failure: processPartition(createProvider(pattern).getDataProcessor(), new double[] {1}) throws a NullPointerException for both "1,2,3,2,1" and "1,{2,3,2}+,1", using the parameters already configured by createProvider().

addPoint() creates nowSection only after the second point, but finish() unconditionally calls closeNowDataSegment() → closeNowSection(), which dereferences it at QetchAlgorithm.java:469. A one-row partition should finish with no matches. Please handle this boundary and add separate ordinary/regex regression tests, including singleton partitions before or after a matching partition.

I reproduced this with both the base implementation (2abe6e925e) and the PR implementation (d1728308b7); this is a pre-existing defect, not a regression introduced by this PR.

@JackieTien97 JackieTien97 changed the title Fix pattern_match state leaking across partitions Fix pattern_match partition isolation and singleton handling Oct 20, 2026
@JackieTien97
JackieTien97 merged commit d5a2da0 into master Oct 20, 2026
35 of 39 checks passed
@JackieTien97
JackieTien97 deleted the codex/fix-pattern-match-partition-state branch October 20, 2026 07:10
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