BobSong-dev opened a new pull request, #7342:
URL: https://github.com/apache/shenyu/pull/7342

   Fixes #7312
   
   ## Background
   
   `DataChangedEvent` is a local Spring event. In cluster mode, 
`DataChangedEventDispatcher`
   skips non-Abstract listeners (websocket push, registry writers) on 
non-master nodes. A write
   that commits on a non-master node therefore never reaches the master node 
that holds the
   gateway sessions: the database row is updated, the push is silently dropped, 
and the gateway
   stays stale until restart. The check also `return`s from inside the listener 
loop, so whether
   AbstractDataChangedListener caches get updated depends on listener iteration 
order.
   
   ## Changes
   
   - Hoist the master check out of the listener loop; on non-master nodes the 
event is handed
     over to the current master over HTTP (`ClusterDataChangedEventForwarder`, 
cluster-only bean);
   - The master-side endpoint (`POST /cluster/data-change-event`) re-publishes 
the event locally,
     so websocket push, long-polling caches and registry writers all observe 
the committed change;
     non-master receivers answer 409 so no delivery loops occur;
   - Skip push listeners with `continue` instead of `return`, making dispatch 
independent of
     listener order and keeping non-master local caches consistent;
   - Forwarding failures are logged with group, event type, size, master 
identity and outcome;
     standalone mode is unchanged (all new beans are 
`shenyu.cluster.enabled`-conditional).
   
   Re-delivery is idempotent because listeners upsert full data snapshots. 
Delivery is
   at-least-once; master failover mid-delivery is logged and left to the next 
configuration
   change or a gateway `MYSELF` resync, which is noted as a known limitation.
   
   ## Verification
   
   Local:
   - `./mvnw test -pl shenyu-admin -Dtest=...` (dispatcher, forwarder, 
controller): 25 tests, 0 failures;
   - `./mvnw test -pl shenyu-admin`: BUILD SUCCESS; Tests run: 1522, Failures: 
0, Errors: 0, Skipped: 1;
   - `./mvnw checkstyle:check -pl shenyu-admin`: passed;
   - `git diff --check`: passed.


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

Reply via email to