yujun777 opened a new pull request, #70892:
URL: https://github.com/apache/doris/pull/70892

   ### 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: #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 #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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to