englefly commented on code in PR #69028:
URL: https://github.com/apache/doris/pull/69028#discussion_r4355526082
##########
fe/fe-core/src/main/java/org/apache/doris/statistics/repository/StatisticsCleaner.java:
##########
@@ -140,6 +140,8 @@ private void clearTableStats() {
}
LOG.info("Table {}.{}.{} with id {} not exist, remove its
table stats record.",
stats.ctlName, stats.dbName, stats.tblName, id);
+ // No table lock: the table is gone, so no load can recreate
the record of this id while the
Review Comment:
Fixed in 4c792cff11f.
The cleaner now takes the **write lock of the recycled table** — the very
instance `RECOVER TABLE`
registers again, and the lock a load holds in `finishTransaction` until it
recreated the record — around
the removal **and** its journal entry, and it checks the catalog again under
that lock:
- if the deletion is applied before the recovery/load, the load journals its
creation after this
`DELETE_TABLE_STATS`, so the replay order matches the master;
- if the load already recreated the record, that record is the one which is
removed, and the replay
removes it as well;
- a table which was recovered between the check and the lock keeps its
statistics.
A record whose table is gone for good (not in the recycle bin, hence not
recoverable) keeps the old
unlocked removal. `CatalogRecycleBin#getRecycledTable` exposes the recycled
instance; the previous
"no lock needed" comment was wrong because `RECOVER TABLE` re-registers the
table with its original id.
Tests:
`StatisticsCleanerTest#testRecycledTableStatsAreRemovedUnderTheTableLock` (the
removal and the
journal entry happen between `writeLock` and `writeUnlock`) and
`StatisticsCleanerTest#testTableRecoveredBeforeTheRemovalKeepsItsStats` (a
table which is back in the
catalog under the lock is left alone). `StatisticsCleanerTest` 3/3,
checkstyle passes.
--
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]