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


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Resource.java:
##########
@@ -350,12 +357,27 @@ public Resource clone() {
         return copied;
     }
 
-    private void notifyUpdate(Map<String, String> properties) {
-        
references.entrySet().stream().collect(Collectors.groupingBy(Entry::getValue)).forEach((type,
 refs) -> {
-            if (type == ReferenceType.CATALOG) {
-                // No longer support resource in Catalog.
+    final Resource getCopiedResourceSnapshot() {
+        String json;
+        readLock();
+        try {
+            synchronized (this) {
+                json = GsonUtils.GSON.toJson(this);

Review Comment:
   This snapshot still includes `Resource.references`, but those references are 
maintained by the storage-policy edit logs, not by `ALTER RESOURCE`. For 
example, `StoragePolicy.init()` adds the policy reference before 
`PolicyMgr.createPolicy()` writes `OP_CREATE_POLICY`; a concurrent `ALTER 
RESOURCE` can snapshot that in-memory `p@POLICY` entry here, and if the FE 
crashes after the ALTER log is durable but before the policy-create log is 
durable, replay installs a resource that says it is used by a policy that does 
not exist. The reverse ordering can also let a later ALTER replay overwrite a 
reference added by a durable policy log. Please keep the existing reference map 
when replaying ALTER, exclude `references` from the ALTER payload, or otherwise 
order policy reference mutations with ALTER snapshots so `OP_ALTER_RESOURCE` 
cannot persist policy-reference state independently of the policy logs.



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