[BUG] Admin cluster drops WebSocket data-change events handled by non-master nodes
Current Behavior
In Admin cluster mode, a configuration write can commit successfully on a non-master node but never reach WebSocket-connected gateways.
DataChangedEvent is a local Spring application event. In DataChangedEventDispatcher#onApplicationEvent, a non-master node returns before invoking non-AbstractDataChangedListener listeners:
if (!(listener instanceof AbstractDataChangedListener)
&& clusterProperties.isEnabled()
&& shenyuClusterSelectMasterService != null
&& !shenyuClusterSelectMasterService.isMaster()) {
LOG.info("received DataChangedEvent, not master, pass");
return;
}WebsocketDataChangedListener is one of the skipped listeners. There is no forwarding/replay from the node that committed the database transaction to the current master.
This produces the observed sequence:
- a load-balanced write request reaches a non-master Admin;
- database data is updated;
- the local WebSocket event is skipped;
- gateway cache remains stale while the socket stays healthy;
- gateway restart sends
MYSELFand reloads the correct database snapshot.
Related but distinct issue: #6461 covers reconnect behavior after an Admin restart.
Reproduction
- Start two Admin instances with cluster mode enabled and a shared database.
- Connect a gateway by WebSocket to the current master.
- Send a selector/rule/plugin update directly to the non-master Admin.
- Verify the database update succeeds and the non-master logs
received DataChangedEvent, not master, pass. - Verify the connected gateway does not receive the update.
- Restart/reconnect the gateway and verify the full snapshot contains the change.
Expected Behavior
A committed configuration change accepted by any Admin node must eventually reach gateways connected to the active master exactly once or through an idempotent/reconcilable path.
Scope
- Define a reliable cross-node handoff for committed data-change events, or route writes to the master before mutation.
- Do not depend on local Spring events alone for cluster-wide propagation.
- Remove listener-order dependence caused by returning from inside the listener loop.
- Preserve standalone behavior.
- Handle master changes during event delivery.
- Ensure rolled-back transactions are not published as committed configuration.
- Add diagnostics containing event group, namespace, source node, master identity, and delivery outcome.
Acceptance Criteria
- Writes sent to either master or non-master Admin reach connected gateways.
- Two-Admin load-balanced E2E covers plugin, selector, rule, metadata, and delete events.
- Master failover during or immediately after a write converges to the database state.
- Delivery is independent of Spring bean/listener iteration order.
- Duplicate delivery is idempotent or deduplicated.
- Standalone WebSocket sync remains unchanged.
- Cluster logs/metrics expose forwarded, skipped, delivered, and failed events.
Source: apache/shenyu