github-actions[bot] commented on code in PR #66287:
URL: https://github.com/apache/doris/pull/66287#discussion_r3755238603
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/stream/BaseTableStream.java:
##########
@@ -113,10 +116,16 @@ public BaseTableStream(String streamName, List<Column>
fullSchema, TableIf baseT
}
public TableIf getBaseTableNullable() {
- if (baseTable == null) {
- baseTable = baseTableInfo.getTableNullable();
+ TableIf cachedBaseTable = baseTable;
+ if (cachedBaseTable instanceof Table && ((Table)
cachedBaseTable).isDropped) {
+ baseTable = null;
+ return null;
+ }
+ if (cachedBaseTable == null) {
+ cachedBaseTable = baseTableInfo.getTableNullable();
Review Comment:
**[P2] Recheck dropped state after resolving a cache miss**
During `RECOVER TABLE`, `innerRecoverTable()` holds A's write lock, but
`Database.registerTable()` publishes A in the ID/name maps before calling
`unmarkDropped()`. An unlocked `table_streams` request can therefore reach this
cache-miss branch while `A.isDropped` is still true. Because the looked-up
value is cached and returned without the dropped check applied to the initial
snapshot, that row reports `OLAP`/enabled/non-stale before recovery has made
the table available. Please make publication atomic to unlocked readers or
apply the same dropped-state check to the resolved candidate, and add a latch
test paused between map publication and `unmarkDropped()`.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java:
##########
@@ -1292,10 +1293,31 @@ private boolean
containsPlanReadLockTable(Collection<TableIf> tableIfs) {
if (tableIf.needReadLockWhenPlan()) {
return true;
}
+ if (tableIf instanceof BaseTableStream) {
+ // Mirror addTablesToLock(): a stream needs no plan lock
itself, but its stable-ID base may need one.
+ TableIf baseTable = ((BaseTableStream)
tableIf).getBaseTableNullable();
Review Comment:
**[P2] Use one stream-base snapshot for preload and locking**
For `Join(S on internal A, external E)`, collection can validate A, A can be
dropped before this preload gate (so the preload result is memoized as
skipped), and A can recover before `lock()` resolves it again and acquires A's
read lock. Binding E then still loads its snapshot/schema while that internal
lock is held, defeating the preload boundary that keeps remote metadata work
outside table locks. Freeze the stable stream-base dependency during collection
and use the same set for both preload gating and ID-ordered locking (or
conservatively treat a collected stream as a possible lock dependency), with a
latch-controlled drop/gate/recover/lock test.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CollectRelation.java:
##########
@@ -235,9 +235,8 @@ private void collectFromUnboundRelation(CascadesContext
cascadesContext,
if (table instanceof View) {
parseAndCollectFromView(tableQualifier, (View) table,
cascadesContext);
}
- // we need to collect stream table's base table as well
if (table instanceof BaseTableStream) {
- collectFromTableStream((BaseTableStream) table, cascadesContext,
tableFrom, unboundRelation);
+ collectFromTableStream((BaseTableStream) table);
Review Comment:
**[P1] Preserve the stream base in MTMV dependency tracking**
Reduced plan:
```text
MTMV M
UnboundRelation(S) // stream over OLAP table T
```
This change validates T but leaves `StatementContext.tables` containing only
S; T is reintroduced only in the local lock queue. Both MTMV creation and every
refresh build `MTMVRelation` from `getTables().values()`, so T is absent. Since
S is not `MTMVRelatedTableIf`, `isSyncWithBaseTable()` treats it as
synchronized and snapshot generation skips it, allowing a commit to T to leave
M considered fresh and absent from T's invalidation relation. Keep the stable
base in a separate ID/object-keyed dependency collection consumed by locking
and MTMV relation/snapshot tracking (without putting it back in the qualifier
cache), and add an async-MV-over-stream refresh test.
--
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]