foxtail463 commented on code in PR #62530:
URL: https://github.com/apache/doris/pull/62530#discussion_r3087978370


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropConstraintCommand.java:
##########
@@ -72,8 +75,14 @@ public void run(ConnectContext ctx, StmtExecutor executor) 
throws Exception {
                     + "falling back to name-based lookup: {}", name, 
e.getMessage());
             tableNameInfo = extractTableNameFromPlan(ctx);
         }
-        Env.getCurrentEnv().getConstraintManager().dropConstraint(
-                tableNameInfo, name, false);
+        Constraint constraint = 
Env.getCurrentEnv().getConstraintManager().getConstraint(tableNameInfo, name);
+        if (constraint == null) {
+            throw new AnalysisException(
+                    String.format("Unknown constraint %s on table %s.", name, 
tableNameInfo));
+        }
+        List<MTMV> dependentMtmvs = 
MTMVUtil.getDependentMtmvsByConstraint(tableNameInfo, constraint);
+        
Env.getCurrentEnv().getConstraintManager().dropConstraint(tableNameInfo, name, 
false);
+        MTMVUtil.invalidateRewriteCaches(dependentMtmvs);

Review Comment:
   The query can be considered concurrent with the DDL before the DROP 
CONSTRAINT statement becomes visible as completed. We do not provide 
statement-internal atomic visibility between constraint metadata mutation and 
MTMV cache invalidation. The live DDL path keeps invalidation failure exposed, 
so DROP does not silently complete with stale caches.



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