Skip to content

Backport #19465: Include pending historical resources in Pipe estimates - #19482

Open
Caideyipi wants to merge 5 commits into
apache:dev/1.3from
Caideyipi:cp/21339dc8-dev-1.3
Open

Caideyipi wants to merge 5 commits into
apache:dev/1.3from
Caideyipi:cp/21339dc8-dev-1.3

Conversation

@Caideyipi

Copy link
Copy Markdown
Collaborator

Backport of #19465 to dev/1.3 (source commit 21339dc).

Scenario and behavior

Suppose a pipe has one real-time TsFile event with a mean collection-invocation count of 100 and two pending historical TsFile insertions. Previously, the remaining-time estimate used only the real-time event (100 work units); it now includes the historical insertions (300 work units), before adding any separate pending progress-report or deletion events.

Real-time DeleteDataNode events remain counted until their references are released. Historical progress-report resources remain distinct from TsFile insertion candidates and are not multiplied by the TsFile invocation average.

Compatibility

In dev/1.3, real-time deletions are carried by PipeSchemaRegionWritePlanEvent, and historical files are queued by PipeHistoricalDataRegionTsFileSource. This backport applies the source behavior through those equivalent APIs and deregisters closed sources from the remaining-event metric.

Validation

  • Spotless formatter passed.
  • Clean DataNode reactor run passed: 27 tests, 0 failures, 0 errors, 0 skipped.

* fix(pipe): account for pending historical events

* test: update historical event count mock

(cherry picked from commit 21339dc)
tsfileEventCount.get(),
pendingHistoricalTsFileEventCount,
pendingHistoricalNonTsFileEventCount,
deletionEventCount.get(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/overview/PipeDataNodeRemainingEventAndTimeOperator.java:166 — Deletion events counted in data-region numerator but delete commits mark the schema-region meter

deletionEventCount is added to totalDataRegionWriteEventCount (line 166), yet in dev/1.3 a delete event is a PipeSchemaRegionWritePlanEvent and EnrichedEvent.isDataRegionEvent() returns false for PipeWritePlanEvents, so PipeDataNodeSinglePipeMetrics.markRegionCommit records delete commits on the schema-region meter. Trigger: a pipe whose only DML is deletions (source.inclusion=data.delete) or any moment with a pending deletion and no data-region commit in the rate window. Result: dataRegionCommitMeter rate is 0, so lines 180-183 yield Double.MAX_VALUE and getRemainingTime() saturates at REMAINING_MAX_SECONDS (1 year) instead of 0/converging (master's PipeDeleteDataNodeEvent is a data-region event, so this mismatch is backport-specific).

Fix: Route DeleteDataNode event commits to the data-region commit meter (e.g., make the delete-plan event report data-region commit rate in PipeEventCommitManager.commit/markRegionCommit), or keep deletionEventCount out of the data-region numerator until a matching deletion rate exists.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching this. In dev/1.3, DeleteDataNode commits are wrapped in PipeSchemaRegionWritePlanEvent, so they were marked as schema-region commits even though deletion events are included in the data-region remaining-work numerator. I updated the event classification so delete-plan commits use the data-region rate and added a regression assertion. The focused DataNode test passes (4 tests).

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Addressed the deletion commit-rate review comment.

  • Finding: DeleteDataNode commits were classified as schema-region commits while their pending events were included in the data-region remaining-work estimate.
  • Fix: Classify delete-plan events as data-region events and add a regression assertion.
  • Validation: mvn clean test -pl iotdb-core/node-commons,iotdb-core/datanode -am --define test=PipeDataNodeRemainingEventAndTimeOperatorTest --define surefire.failIfNoSpecifiedTests=false --define forkCount=1 -T 1 passed (4 tests, 0 failures).
  • Source PR/commit: Include pending historical resources in Pipe estimates #19465 / 21339dc8b6270bd2edefe4c83bdc845c9dfc4a21.
  • Target base: dev/1.3 at 8a6963b26b74e3bdcb9913e5bbb0d628c7e0fc52.
  • Reviewed head: fc004133585e7c3ab69958d98cc5f0ca402aab75; final local and verified remote head: df410d6c8945b33bacb20daf021d13a84d9fda9f.

.map(IoTDBDataRegionSource::getHistoricalTsFileInsertionEventCount)
.reduce(Integer::sum)
.orElse(0)
.mapToLong(IoTDBDataRegionSource::getHistoricalEventCount)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

major iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/metric/overview/PipeDataNodeRemainingEventAndTimeOperator.java:123 — Switching remaining-event source to getHistoricalEventCount breaks existing dev/1.3 test

getRemainingNonHeartbeatEvents() now sums IoTDBDataRegionSource.getHistoricalEventCount(), but PipeDataNodeSinglePipeMetricsTest#testDeregisterClearsOperatorsWhenMetricsAreUnbound (added to dev/1.3 by #19390, kept unchanged here) still stubs only getHistoricalTsFileInsertionEventCount() -> 1 at line 130 and asserts remaining events == 1 at lines 142-143. The mock's getHistoricalEventCount() returns 0, so the assertion becomes expected:<1> but was:<0> and the DataNode test run fails.

Fix: Update that test to stub getHistoricalEventCount() to 1 (as the source commit did for the same test), or stub both getHistoricalEventCount() and getHistoricalTsFileInsertionEventCount().

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in commit c26f88f6494d6a8ceced2858c781c72e5bb9fb34. PipeDataNodeSinglePipeMetricsTest#testDeregisterClearsOperatorsWhenMetricsAreUnbound now stubs getHistoricalEventCount() to 1, matching the accessor used by getRemainingNonHeartbeatEvents(). The focused clean DataNode test run passed: 6 tests, 0 failures, 0 errors, 0 skipped.

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Review follow-up for reviewed head 9f5b181634ec32b29982a70297c978b0d9e06353:

  • Updated the deregistration test mock to stub getHistoricalEventCount(), matching the aggregate getter used by the remaining-event calculation. This is a test-only compatibility change; the deletion-event classification fix and regression remain in the PR.
  • Source PR/commit: Include pending historical resources in Pipe estimates #19465 / fc004133585. Target base: dev/1.3 at 450e3158fea7eae8e8b930db84fa7a2409403960.
  • Validation: Spotless passed; the clean targeted DataNode run passed (6 tests, 0 failures, 0 errors, 0 skipped).
  • Final local and confirmed remote head: c26f88f6494d6a8ceced2858c781c72e5bb9fb34. The PR remains open.


@Override
public int getPendingQueueSize() {
public synchronized int getPendingQueueSize() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/source/dataregion/historical/PipeHistoricalDataRegionTsFileSource.java:999 — Synchronized pending-count getters block SHOW PIPES and metric gauges during historical start/supply

getPendingQueueSize()/getPendingTsFileInsertionEventCount() are now synchronized, so SHOW PIPES and the UNPROCESSED_HISTORICAL_TSFILE_COUNT/remaining-event gauges (via IoTDBDataRegionSource.getHistoricalEventCount/getHistoricalTsFileInsertionEventCount) wait on the extractor monitor, which start() holds across the data-region flush + pinning of all TsFiles and supply() holds across the TsFile hardlink/copy. hasBeenStarted is set before historicalExtractor.start(), so the wait is reachable; these reads took no lock before.

Fix: Publish the pending counters (and pendingQueue) as volatile fields written under the lock and keep the getters non-blocking, or move flush/pinning out of the synchronized start()/supply().

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the report. I kept the mutable pendingQueue protected by the source monitor and added a volatile queue-size snapshot plus a volatile insertion count. Both getters are now lock-free, and the snapshot is updated when the queue is initialized, polled, or closed. The regression tests cover the values after polling/close and verify that both getters return while the source monitor is held. The focused DataNode test class passes (24 tests, 0 failures, 0 errors, 0 skipped).

@Caideyipi

Copy link
Copy Markdown
Collaborator Author

Comment-handling follow-up for reviewed head c26f88f6494d6a8ceced2858c781c72e5bb9fb34:

  • Finding: Synchronized historical pending-count getters could block SHOW PIPES and metric gauges while extraction holds the source monitor during start()/supply().
  • Fix: Keep pendingQueue monitor-protected; expose a volatile queue-size snapshot and volatile insertion count through lock-free getters. Update snapshots on initialization, polling, and close; add concurrency and count-update regression coverage.
  • Validation: Spotless passed; mvn clean test -pl iotdb-core/datanode -am -Dtest=PipeHistoricalDataRegionTsFileSourceTest -Dsurefire.failIfNoSpecifiedTests=false -DforkCount=1 -T 1 passed (24 tests, 0 failures, 0 errors, 0 skipped; Maven heap capped at 2 GiB).
  • Final local and confirmed remote head: a5a6ae1a83fdae450cf910f92b7bba5bdf58ba6a. The PR remains open.

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.

2 participants