imbajin commented on code in PR #3237:
URL: https://github.com/apache/hugegraph/pull/3237#discussion_r4101033155


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java:
##########
@@ -315,37 +397,57 @@ private void invalidateCache(HugeType type, Id id) {
     @Override
     protected void updateSchema(SchemaElement schema,
                                 Consumer<SchemaElement> updateCallback) {
+        long generation = this.arrayCaches.generation();
         super.updateSchema(schema, updateCallback);
 
-        this.updateCache(schema);
-        // Status transitions are internal bookkeeping; notifying here causes a
-        // broadcast storm for every updateSchemaStatus() call from background 
jobs.
+        this.updateCache(schema, generation);
+        // No meta event here: one per updateSchemaStatus() call from 
background
+        // jobs would be a broadcast storm. The schema version has no fan-out,
+        // other servers check it at most once per reconcile interval.
+        this.bumpSchemaVersion();
     }
 
     @Override
     protected void addSchema(SchemaElement schema) {
+        long generation = this.arrayCaches.generation();
         super.addSchema(schema);
 
-        this.updateCache(schema);
+        this.updateCache(schema, generation);
 
+        this.bumpSchemaVersion();

Review Comment:
   ⚠️ The schema write completes in `super.addSchema()` before this separate PD 
version write; `updateSchema()` and `removeSchema()` use the same ordering. If 
the writer exits between those calls, peers keep the previously applied version 
and `SchemaVersionReconciler` skips them, so they can continue serving stale 
schema until another mutation or a peer restart. Please make the mutation 
notification recoverable across this crash window, for example by atomically 
storing a revision or publishing a repair revision during graph startup, and 
add a recovery test.



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