Repository navigation
[fix](stream) Calibrate changelog row counts with lagging reports - #70892
Conversation
### Background FE estimates retained changelog rows from periodic tablet statistics and visible write deltas. The periodic count accounts for row removal, including TTL cleanup. Tablet reports are sampled independently and may arrive after newer writes reach FE. ### What problem does this PR solve? Issue Number: None Related PR: apache#69896 (introduced the report-version guard) PR Type: Bugfix Problem Summary: A complete tablet report can always arrive one write behind. FE discarded such reports, leaving TTL-reclaimed rows in the estimate as each new write was added. In the deterministic test, each report observes 100 retained rows and lags a 10-row write by one version. The old estimate reaches 120 in round two and 150 in round five. This change keeps it at 110 throughout. ### Details - **Frequency:** Always when each complete report lags the latest counted write and retained rows are being removed. - **Root cause:** Both tablet statistics managers and MaterializedIndex required a report to reach the latest applied delta before replacing the estimate. FE retained the identities of applied Cloud writes for deduplication, but did not retain the row deltas needed to combine a lagging snapshot with newer writes. - **Why existing tests missed it:** MaterializedIndexTest and TabletStatMgrTest checked stale-report protection and an eventual current report, leaving repeated lagging reports untested. The changelog_p0 immediate-count and Cloud subtransaction regression suites suspend periodic publication to observe the immediate estimate. - **Fix:** Retain a bounded history of write deltas and reapply only deltas newer than the highest tablet report version in a complete aggregate. Choosing the freshest report per tablet and requiring nondecreasing coverage prevents a stale aggregate from replacing newer coverage. Cloud keeps commit deduplication and shared-nothing keeps per-tablet accumulation within a publish version. - **Other paths and branches:** Shared-nothing and Cloud are covered. The report guard introduced by apache#69896 is absent from the checked upstream 3.1, 4.0, 4.1, and 4.2 release branches. - **Behavior change:** A lagging complete report can correct the retained count. During mixed-version sampling, writes through the newest sampled version may be temporarily undercounted. At 1,024 tracked versions for an index, new versions rely on periodic counts until older entries retire. ### Testing - The new version-lag test failed on the baseline with expected 110 and actual 120 in round two. It passes for both storage modes with the fix. - All 109 tests passed across MaterializedIndexTest, TabletStatMgrTest, AnalysisManagerTest, and CloudGlobalTransactionMgrTest using separate JVMs and the standard run's reactor test classpath. - FE core Checkstyle passed with zero violations. No live-cluster regression was run. ### Release note The changelog row count can be recalibrated by periodic statistics during continuous writes. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready
|
run buildall |
|
/review |
There was a problem hiding this comment.
Reviewed PR 70892 at exact head 172a58b4c1c575a6a9d79d9a782d4c92bf1996b1 against the supplied base. The change correctly targets lagging complete tablet reports: monotonic report selection, local/Cloud producer separation, duplicate Cloud commit handling, table-lock serialization, restore reset, and Cloud refresh/backoff paths were traced.
One P2 issue remains. The new bounded TreeMap history is shared by local publish and Cloud commit deltas. Once 1,024 consecutive versions fill it, the next visible delta is silently omitted without a retained refresh watermark. A report that stops at the last retained version then clears the map and marks the count reported, so the omitted write can remain absent from stream row-count estimates until a later report reaches it.
The mixed min/max report undercount was independently checked and dismissed as the explicitly documented temporary behavior of this PR; no other producer, selection, locking, lifecycle, protocol, or persistence issue was substantiated. The changed tests cover lagging reports, duplicate commits, restore, partial/empty reports, and backoff, but do not cover capacity overflow followed by a lagging report. No additional user focus was supplied. Validation here was static inspection only; no builds or tests were run.
The review converged after two bounded rounds with no prior inline blocking findings to carry forward.
Review converged after 2 round(s).
| Long previous = changelogRowCountDeltas.get(version); | ||
| // Bound the history of unapplied reports. At capacity, periodic counts still include writes | ||
| // whose deltas were skipped here. | ||
| if (previous == null && changelogRowCountDeltas.size() >= MAX_CHANGELOG_ROW_COUNT_DELTAS |
There was a problem hiding this comment.
[P2] Preserve skipped deltas when the bounded history is full. Both addChangelogRowsFromPublish and Cloud addChangelogRows now hit this guard, so after 1,024 consecutive versions the next visible delta is omitted from rowCount and lastChangelogDeltaVersion. If the next complete tablet report stops at the last retained version, setChangelogReportedRowCount clears the map and marks the index reported; the omitted version has no watermark and can remain absent from the stream estimate until a later report reaches it. Keep a pending/refresh marker for skipped versions or coalesce adjacent versions so a report cannot retire the need to refresh past an unaccounted write.
### Background Stream planning estimates retained changelog rows using periodic tablet statistics and visible write notifications. Periodic statistics reflect row removal from TTL cleanup, while write notifications keep the estimate responsive between reports. Tablets are sampled independently, so a complete set of samples can lag the latest write. ### What problem does this PR solve? Issue Number: None Related PR: apache#69896 (introduced the report-version guard) PR Type: Bugfix Problem Summary: Continuous writes can keep every complete report one version behind, preventing FE from removing expired rows from its estimate. FE now uses each complete report with nondecreasing coverage to reset the estimate. In a five-round test with 100 retained rows and a 10-row write ahead of every report, the original estimate grows from 110 to 150. With the fix, it returns to 100 after each report. ### Details - **Change map:** FE catalog (89 additions, 69 deletions) updates report aggregation and limits immediate estimates. FE unit tests (131 additions, 44 deletions) exercise both storage modes, capacity, retries, and Cloud polling. - **Frequency:** Always in the deterministic case where each complete report lags a counted write. TTL cleanup makes the stale estimate diverge from retained rows. - **Root cause:** The tablet statistics managers and MaterializedIndex required periodic coverage to reach the latest applied write. A complete but lagging report could never correct the estimate during continuous writes. - **Why existing tests missed it:** The FE unit tests covered an eventual up-to-date report. The immediate-count and Cloud subtransaction suites pause periodic publication to check write estimates. Neither exercised repeated lagging reports. - **Fix:** Replace the estimate with the complete report sum and begin a new window with a 128-write-version budget per changelog index. Tablet counts can include writes newer than their reported version, so replaying prior deltas can double count. Preserve a version boundary to suppress already observed writes after a reset. Advance Cloud's refresh watermark even when the estimate is at capacity. - **Other paths and branches:** Covers shared-nothing publish and Cloud commit notifications. The guard from apache#69896 is absent from the checked upstream 3.1, 4.0, 4.1, and 4.2 branches. - **Behavior change:** The estimate can temporarily omit recently written rows when a report lags or the budget is exhausted. A first notification that arrives after a sample already included its rows can briefly inflate the estimate. A later complete report recalibrates it. ### Testing - On the prior PR head, the overlap assertion returned 17 instead of 12. The lagging-report assertion returned 110 instead of 100. The capacity assertion returned 138 instead of 128. - All 118 tests passed with the updated FE classes across MaterializedIndexTest, TabletStatMgrTest, StreamRowCountEstimatorTest, AnalysisManagerTest, and CloudGlobalTransactionMgrTest. The mode-2 polling test checks that a skipped write triggers a fresh tablet stats request. - FE core Checkstyle passed. Producer timing scenarios were reproduced as FE inputs. Live-cluster regression was not run. ### Release note Periodic statistics can correct the estimated changelog row count during continuous writes. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready
|
run buildall |
|
/review |
Local pipeline review — ✅ PASSschema: doris-repo-review/v1
status: PASS
pr: apache/doris#70892
commit: cb54db29963784960e88c0ab8d3122114f3c6457
base: a0662fea1d048695b751edc9b69933a12cd68eaf
reviewed_at: 2026-11-23T21:50+08:00
reviewer: yujun777
model: gpt-6-astra
effort: xhigh
findings: {blocker: 0, major: 0, minor: 0, nit: 0}
rounds: 1
converged: trueNotes for maintainers
Reviewed locally with the |
There was a problem hiding this comment.
Static review of PR 70892 at exact head cb54db2 converged after 2 bounded rounds. No new inline findings are submitted. Existing inline P2 comment 4665743842 remains known and applicable to the bounded-history capacity case (the current head uses a 128-version limit); it is not duplicated, and there are no existing P0/P1 findings to carry forward.
The change meets its stated goal of allowing complete lagging reports to recalibrate changelog estimates. Local publish and Cloud commit paths, duplicate handling, report version selection, visible-version checks, table-write-lock serialization, restore reset, and Cloud refresh/backoff were traced. The mixed min/max report undercount is explicitly documented as temporary behavior and is retried through the refresh watermark. The no-report completeness candidate was dismissed because the updated regression explicitly preserves the last useful changelog estimate when no replica currently qualifies. No new configuration, protocol, persistence, or static-initialization concern was found.
Changed tests cover local and Cloud lagging reports, duplicate commits, partial and empty reports, restore, and polling. Validation for this review was static inspection only; no builds, tests, benchmarks, or live-cluster checks were run. The user review-focus file contains no additional focus points.
Review converged after 2 round(s).
Background
Stream planning estimates retained changelog rows using periodic tablet statistics and visible write notifications. Periodic statistics reflect row removal from TTL cleanup, while write notifications keep the estimate responsive between reports. Tablets are sampled independently, so a complete set of samples can lag the latest write.
What problem does this PR solve?
Issue Number: None
Related PR: #69896 (introduced the report-version guard)
PR Type: Bugfix
Problem Summary:
Continuous writes can keep every complete report one version behind, preventing FE from removing expired rows from its estimate. FE now uses each complete report with nondecreasing coverage to reset the estimate. In a five-round test with 100 retained rows and a 10-row write ahead of every report, the original estimate grows from 110 to 150. With the fix, it returns to 100 after each report.
Details
Testing
Release note
Periodic statistics can correct the estimated changelog row count during continuous writes.
Check List (For Author)