dpol1 opened a new pull request, #3017:
URL: https://github.com/apache/hugegraph/pull/3017

   <!-- 
     Thank you very much for contributing to Apache HugeGraph, we are happy 
that you want to help us improve it!
   
     Here are some tips for you:
       1. If this is your first time, please read the [contributing 
guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
   
       2. If a PR fix/close an issue, type the message "close xxx" (xxx is the 
link of related 
   issue) in the content, GitHub will auto link it (Required)
   
       3. Name the PR title in "Google Commit Format", start with "feat | fix | 
perf | refactor | doc | chore", 
         such like: "feat(core): support the PageRank algorithm" or "fix: wrong 
break in the compute loop" (module is optional)
         skip it if you are unsure about which is the best component.
   
       4. One PR address one issue, better not to mix up multiple issues.
   
       5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click 
it directly after 
   published)
   -->
   
   ## Purpose of the PR
   
   - close #3012 <!-- or use "fix #xxx", "xxx" is the ID-link of related issue, 
e.g: close #1024 -->
   
   <!--
   Please explain more context in this section, clarify why the changes are 
needed. 
   e.g:
   - If you propose a new API, clarify the use case for a new API.
   - If you fix a bug, you can clarify why it is a bug, and should be 
associated with an issue.
   -->
   
   Cache producers in the legacy `EventHub` path were emitting past-tense 
action                                                                          
               
     names (`invalided` / `cleared`) while local cache listeners only matched 
the
     present-tense actions (`invalid` / `clear`). On single-node deployments, 
or                                                                              
             
     whenever the cache RPC bridge in `StandardHugeGraph.AbstractCacheNotifier` 
was                                                                             
           
     not active, those local cache invalidation events were silently dropped: 
no                                                                              
             
     error, no warning, just stale cache.                                       
                                                                                
           
                                                                                
                                                                                
           
     The fix aligns producers, listeners, and the bridge on the present-tense   
                                                                                
           
     constants, removes the obsolete past-tense ones, and wires 
`notifyExcept(...)`
     so the bridge does not loop back into itself once both ends speak the same 
                                                                                
           
     action name.                                                               
                                                                                
           
                                                                                
                                                                                
           
     ## Main Changes                                                            
                                                                                
           
                                                               
     - Drop `Cache.ACTION_INVALIDED` / `Cache.ACTION_CLEARED`. All producers    
                                                                                
           
       (`CachedGraphTransaction`, `CachedSchemaTransaction`) now emit
       `Cache.ACTION_INVALID` / `Cache.ACTION_CLEAR`, matching what local 
listeners                                                                       
                 
       and `RaftContext` already expect.                                        
                                                                                
           
     - Update `StandardHugeGraph.AbstractCacheNotifier` to listen on the        
                                                                                
           
       present-tense actions and to forward through 
`EventHub.notifyExcept(...)` so                                                 
                                       
       the bridge does not re-receive its own re-emit.                          
                                                                                
           
     - Add `EventHub.notifyExcept(event, ignoredListener, args...)` so a caller 
can                                                                             
           
       notify everyone on the hub except the listener that originated the 
event.                                                                          
                 
       The signature is documented as a public API on `EventHub`, `notify(...)` 
                                                                                
           
       is unchanged and now delegates internally.                               
                                                                                
           
     - Use `notifyExcept(...)` from the cache transactions and from             
                                                                                
           
       `AbstractCacheNotifier`, with the registered cache listener as the 
ignored                                                                         
                 
       one, so producers do not feed their own listener and the RPC re-emit 
does                                                                            
               
       not loop the bridge.                                                     
                                                                                
           
     - Track the registered cache listener per graph in
       `GraphTransaction.graphCacheEventListeners` and in a matching map inside
       `CachedSchemaTransaction`, with owner-aware teardown on close. This is 
the
       minimum needed for `notifyExcept(...)` to exclude the listener that is
       actually registered on the hub: with the old per-instance lambda +
       `containsListener(...)` / boolean guard pattern, only the first 
transaction
       per graph registered a listener, while later transactions could call
       `notifyExcept(...)` with a lambda that was never registered. In that 
case the
       real registered listener was not excluded and could still process the
       transaction's own local emit.                                            
                                                          
                                                                                
                                                                                
           
     `CachedSchemaTransactionV2` is intentionally not touched here. That class 
was
     just adjusted in #3011 for HStore/V2 schema cache propagation through
     `MetaManager`. The remaining `containsListener(...)` guard there is a 
related
     listener-lifecycle concern, not the action-name mismatch fixed in this PR; 
it
     should be handled in a follow-up that audits the remaining V2 path and, if
     needed, moves cache listener ownership to a ref-counted holder keyed by 
graph
     identity and `EventHub`.                                                   
                                                                                
                 
                                                                                
                                                                                
           
     ## Verifying these changes                                                 
                                                                                
           
                                                               
     - [ ] Trivial rework / code cleanup without any test coverage. (No Need)   
                                                                                
           
     - [ ] Already covered by existing tests, such as *(please modify tests 
here)*.
     - [x] Need tests and can be verified as follows:                           
                                                                                
           
         - `EventHubTest#testNotifyExcept` covers the new `notifyExcept(...)`
           semantics, including `ANY_EVENT` listeners and the ignored-listener  
                                                                                
           
           exclusion.                                                           
                                                                                
           
         - 
`CachedSchemaTransactionTest#testLegacySchemaChangeEmitsActionInvalid`          
                                                                                
           asserts the schema producer now emits `ACTION_INVALID` end-to-end.   
                                                                                
           
         - 
`CachedSchemaTransactionTest#testListenerRegistryClearedOnCloseAndRebuiltOnReopen`
                                                                              
           asserts that closing a graph drops its entry from the per-graph      
                                                                                
           
           listener registry and that a subsequent transaction registers a 
fresh                                                                           
                
           listener instead of reusing the closed reference.                    
                                                                                
           
         - 
`CachedSchemaTransactionTest#testCacheNotifierLocalEventCallsProxyOnce`         
                                                                                
           and `testCacheNotifierRpcInvalidDoesNotLoopToProxy` cover the bridge 
                                                                                
           
           no-loop behavior.                                                    
                                                                                
           
          - `CachedGraphTransactionTest#testClearCacheEmitsActionClear` asserts
             graph cache clears now emit `ACTION_CLEAR`.
          - `CachedGraphTransactionTest#testVertexMutationEmitsActionInvalid`
             asserts graph vertex mutations now emit `ACTION_INVALID`.
          - 
`CachedGraphTransactionTest#testClosingNonOwnerKeepsGraphCacheListenerRegistered`
             asserts that closing a graph transaction which reused an existing
             per-graph listener does not unregister the shared graph cache 
listener.
                                                                                
                 
                                                                                
                                                                                
           
     ## Does this PR potentially affect the following parts?   
                                                                                
                                                                                
           
     - [ ] Dependencies                                        
     - [ ] Modify configurations                                                
                                                                                
           
     - [x] The public API                                      
     - [ ] Other affects
     - [ ] Nope                                                                 
                                                                                
           
      
     `EventHub.notifyExcept(...)` is a new public method; existing 
`notify(...)`                                                                   
                        
     behavior is unchanged.                                    
                                                                                
                                                                                
           
     ## Documentation Status                                   
   
     - [ ] `Doc - TODO`
     - [ ] `Doc - Done`
     - [x] `Doc - No Need`
   


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