github-actions[bot] commented on code in PR #66370:
URL: https://github.com/apache/doris/pull/66370#discussion_r3843123946


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java:
##########
@@ -263,6 +263,7 @@ public AbstractInsertExecutor initPlan(ConnectContext ctx, 
StmtExecutor stmtExec
             // Each internal attempt must repin connector metadata; retaining 
the previous writer schema can
             // plan defaults and partition fields against the table version 
that triggered the retry.
             ctx.getStatementContext().resetConnectorStatementScope();
+            
ctx.getStatementContext().resetMaterializedViewStateForPlanningAttempt();

Review Comment:
   **[P1] Clear the cached insert target before retrying**
   
   This new attempt boundary still leaves `insertTargetTables` alive, so a 
same-name replacement can make the retry loop permanently reject the current 
target:
   
   ```text
   attempt 1: resolve/collect A; post-plan lookup sees B -> ID retry
   attempt 2: resolve and bind B; CollectRelation reuses cached A
              insertTargetSchema=A; schema fence compares against B -> retry to 
failure
   ```
   
   `getAndCacheTable(..., INSERT_TARGET, ...)` uses `computeIfAbsent`, while 
`BindSink.bind` resolves the live table separately. Thus B can remain 
authoritative for every later lookup and the loop still ends with `Could not 
get target table lock`. The new test misses this because it returns B only once 
and switches back to A on the next attempt. Please clear both the insert-target 
cache and its derived schema at every `initPlan` attempt, and keep B 
authoritative in the retry test. This is distinct from the existing QUERY-cache 
and MV-output threads: it is the INSERT_TARGET cache used by this 
target-generation retry.
   



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