You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by ch...@apache.org on 2026/10/18 14:12:48 UTC
(eventmesh) 05/06: [ISSUE #5421] Resolve the advertised address before the first heartbeat
This is an automated email from the ASF dual-hosted git repository.
qqeasonchen pushed a commit to branch fix/cluster-ownership-e2e
in repository https://gitbox.apache.org/repos/asf/eventmesh.git
commit 156fcdde99fc815356e3b42a22f41b47da3eb7f6
Author: qqeasonchen <ch...@apache.org>
AuthorDate: Sun Oct 18 21:50:47 2026 +0800
[ISSUE #5421] Resolve the advertised address before the first heartbeat
enableCluster() built ClusterMembership with the instance id as its "address" and then
scheduled the heartbeat with an initial delay of 0, while the advertised address is only
resolved later in startupInternal(). The first beats therefore registered
ip=<instanceId>, port=0 — an unroutable peer entry that /session/recommend and
HttpForwarder resolve against (and that PartitionAssigner happily spreads partitions over).
Fix: resolve the same address startupInternal() uses (-Deventmesh.http.advertisedAddr,
else localIP:httpPort) and set it on ClusterMembership before the scheduler is created, so
not a single beat can be published with the placeholder.
---
.../eventmesh/runtime/boot/EventMeshApplication.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshApplication.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshApplication.java
index 9f88b7359..58684314f 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshApplication.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/EventMeshApplication.java
@@ -234,6 +234,16 @@ public class EventMeshApplication {
// 1. ClusterMembership — heartbeat value carries the fencing token + load snapshot.
this.clusterMembership = new org.apache.eventmesh.runtime.cluster.ClusterMembership(
metaStore, selfInstanceId, selfInstanceId, 15_000L, System::currentTimeMillis, selfToken);
+ // The heartbeat below starts with an initial delay of 0, so it can fire BEFORE start() has
+ // resolved the advertised address (startupInternal sets it right before the traffic server
+ // binds). Until then the membership carried the instance id as its "address", and the first
+ // beats therefore published ip=<instanceId>, port=0 — an unroutable registration that peers
+ // mirror in their instance table (and could pick as a /internal/forward or /session/recommend
+ // target). Resolve the same address the traffic server will use, BEFORE scheduling.
+ String selfAddr = System.getProperty("eventmesh.http.advertisedAddr", "");
+ clusterMembership.setSelfAddress(selfAddr.isEmpty()
+ ? org.apache.eventmesh.common.util.IPUtils.getLocalAddress() + ":" + httpPort
+ : selfAddr);
org.apache.eventmesh.runtime.ingress.LoadMeter lm = runtime.ingress().loadMeter();
if (lm != null) {
this.clusterMembership.withLoadSupplier(() -> {
@@ -451,6 +461,13 @@ public class EventMeshApplication {
if (sessionRouter != null) {
sessionRouter.shutdown();
}
+ // Deregister this instance's subscriptions from the shared Meta BEFORE leaving the
+ // cluster. Traffic is already stopped (servers above), so no new subscription can arrive;
+ // dropping the rest now keeps the entry from outliving the instance — peers mirror that
+ // prefix and would keep forwarding to this (dead) URL and pulling partitions for topics
+ // whose only subscriber lived here. Must run while this instance's own Meta client is
+ // still alive: with nacos-client 2.1.1 a foreign client's deregister is silently ignored.
+ runtime.ingress().dropAllClusterSubscriptions();
// §13.6.4 step 5 / G12: release the partition lease so peers re-assume ownership without
// waiting for the TTL (15s) to expire — minimises the handover gap on graceful shutdown.
if (heartbeatScheduler != null) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org