Skip to content

Commit 9c8100c

Browse files
committed
[chore](stream) Document stream base lock handling
### What problem does this PR solve? Issue Number: close apache#65418 Related PR: apache#66287 Problem Summary: Document why stream base tables are validated by stable ID without entering the qualifier relation cache, and why implicit base dependencies are expanded only in the local ID-ordered planner lock queue. The comments preserve the concurrency invariant behind the relation-cache collision fix. ### Release note None ### Check List (For Author) - Test: FE unit test - ./run-fe-ut.sh --run org.apache.doris.nereids.StatementContextTest,org.apache.doris.nereids.trees.plans.ExplainTableStreamPlanTest - Behavior changed: No - Does this need documentation: No
1 parent a7850ad commit 9c8100c

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎fe/fe-core/src/main/java/org/apache/doris/nereids/StatementContext.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,7 @@ private boolean containsPlanReadLockTable(Collection<TableIf> tableIfs) {
12941294
return true;
12951295
}
12961296
if (tableIf instanceof BaseTableStream) {
1297+
// Mirror addTablesToLock(): a stream needs no plan lock itself, but its stable-ID base may need one.
12971298
TableIf baseTable = ((BaseTableStream) tableIf).getBaseTableNullable();
12981299
if (baseTable != null && baseTable.needReadLockWhenPlan()) {
12991300
return true;
@@ -1303,6 +1304,11 @@ private boolean containsPlanReadLockTable(Collection<TableIf> tableIfs) {
13031304
return false;
13041305
}
13051306

1307+
/**
1308+
* Add explicit relations and stable-ID stream bases to the local ID-ordered lock queue. Stream bases must not be
1309+
* added to the qualifier relation maps because a concurrent rename can make a base qualifier collide with an
1310+
* explicitly resolved relation.
1311+
*/
13061312
private void addTablesToLock(PriorityQueue<TableIf> tableIfs, Collection<TableIf> tables) {
13071313
tableIfs.addAll(tables);
13081314
for (TableIf tableIf : tables) {

‎fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/CollectRelation.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ private void collectFromUnboundRelation(CascadesContext cascadesContext,
235235
if (table instanceof View) {
236236
parseAndCollectFromView(tableQualifier, (View) table, cascadesContext);
237237
}
238-
// we need to collect stream table's base table as well
239238
if (table instanceof BaseTableStream) {
240239
collectFromTableStream((BaseTableStream) table);
241240
}
@@ -313,6 +312,11 @@ protected void parseAndCollectFromView(List<String> tableQualifier, View view, C
313312
parentContext.addPlanProcesses(viewContext.getPlanProcesses());
314313
}
315314

315+
/**
316+
* Validate the stream base by stable ID without caching it under display qualifiers. A concurrent rename can
317+
* make that qualifier belong to an explicitly resolved relation; stream lock dependencies are expanded separately
318+
* in {@link StatementContext#lock()}.
319+
*/
316320
private void collectFromTableStream(BaseTableStream tableStream) {
317321
if (tableStream.getBaseTableNullable() == null) {
318322
throw new AnalysisException("Table ["

0 commit comments

Comments
 (0)