github-actions[bot] commented on code in PR #66370:
URL: https://github.com/apache/doris/pull/66370#discussion_r3749386719
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ExecuteCommand.java:
##########
@@ -91,6 +91,9 @@ public void run(ConnectContext ctx, StmtExecutor executor)
throws Exception {
}
PrepareCommand prepareCommand = preparedStmtCtx.command;
StatementContext statementContext =
preparedStmtCtx.getStatementContext();
+ // Prepared statements reuse StatementContext across executions.
Discard partition and MV
+ // planning results collected by the previous execution before
planning the current one.
+ statementContext.resetMaterializedViewStateForPreparedExecution();
Review Comment:
**[P1] Reset MV outputs before an internal replan**
After this reset, `run` replaces the executor's parsed statement with the
prepared inner plan and calls `executor.execute()`. If that attempt hits a
`needRetryWithReplan` error, the nested `queryRetry` loop calls
`execute(queryId)` again on the same `StatementContext`; it no longer re-enters
`ExecuteCommand`, so this reset is skipped. For example, attempt 1 can cache
valid MV partitions `{p1,p2}`, then an E-230 retry disables the cloud version
cache and recomputes only `{p1}`, but `isMVPartitionValid` uses `putIfAbsent`,
leaving `{p1,p2}` for `PartitionCompensator`; retained `preMvRewritten` can
also suppress all CBO MV rules on attempt 2. The insert target-ID/schema-change
retry loop has the same attempt-boundary gap. Please clear the attempt-produced
MV caches/plans/flags before every actual replan and add a retry test that
proves the next attempt consumes freshly computed validity.
--
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]