You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "qqeasonchen (via GitHub)" <gi...@apache.org> on 2026/10/18 13:31:46 UTC

[I] [Bug] Cluster-wide subscription discovery exposes only one subscriber per runtime (naming instance collision) (eventmesh)

qqeasonchen opened a new issue, #5420:
URL: https://github.com/apache/eventmesh/issues/5420

   ### Describe the bug
   
   Cluster-wide subscription discovery only ever exposes **one subscriber per runtime**. With two clients subscribed on the same instance, the peer that mirrors `/em/subs/*` ends up holding just one of them, so events pulled on the partition owner are routed to that single target and the other subscriber receives nothing — no error, no log.
   
   Reproduced with a live Nacos 2.1.1 through the runtime's own `MetaStore`:
   
   ```
   put(/em/subs/t/c1, v1)  -> listing {c1}
   put(/em/subs/t/c2, v2)  -> listing {c2}      # c1 gone
   put(/em/subs/t/c3, v3)  -> listing {c3}      # c2 gone
   ```
   
   The same three registrations posted over the Nacos **HTTP** API all survive (3 instances), so the loss comes from the client library: a nacos-client 2.1.1 connection publishes at most **one instance per service** — each further `registerInstance(service, instance)` on the same client silently replaces the previous one.
   
   ### Impact
   
   `ClusterSubscriptionStore` is fed from that listing, so its mirror loses entries and `ClusterCoordinator.targetsFor(...)` returns a single target. Subscribers on the same instance as another subscriber starve; e2e symptom: subscriber `c-pin-B` (alive the whole time) stopped receiving right after a second clientId re-subscribed on its instance.
   
   ### Reproduction
   
   E2E `ClusterBalanceAndResilienceE2EIntegrationTest#clientsPinnedToStoppedInstanceAreTakenOverWithoutLoss`: two subscribers, one per instance; after instance A stops, the A-side client re-subscribes on B — and B's own subscriber stops receiving. With the fix, all 10/10 events reach both subscribers.
   
   ### Root cause
   
   `NacosMetaStore` published **one NamingService instance per subscription** (`subInstance(key, value)` → `registerInstance`). Because the client can only hold one instance per service, each new subscription evicted the previous one on the server, and the next `refreshSubSnapshot()` diff fired a spurious *removal* for the evicted key on every peer.
   
   A second, related defect made it permanent: `refreshSubSnapshot()` treated an empty/partial listing (naming client reconnecting) as "every subscriber left", wiping the mirror — and since a refresh only runs on a naming event, nothing ever restored it.
   
   ### Fix
   
   `eventmesh-runtime/.../cluster/NacosMetaStore.java`
   
   - publish **one** NamingService instance per runtime (`subs-<uuid>`, stable endpoint) whose metadata carries the runtime's whole subscription set as `sub:<base64 key> = <base64 value>` entries; a subscription add/remove is a cheap re-registration of that same instance, and the instance is deregistered when the last local subscription goes away;
   - `namingSubList()` merges the metadata of every published instance (and still understands the legacy `key`/`value` metadata shape);
   - `refreshSubSnapshot()` ignores an empty listing while it still mirrors subscriptions, with a WARN, instead of wiping the mirror.
   
   ### Verification
   
   - Probe against a live Nacos 2.1.1: three subscription keys → three visible entries (before: one).
   - E2E `clientsPinnedToStoppedInstanceAreTakenOverWithoutLoss` passes (it failed deterministically before), and the whole balance/takeover suite stays green.
   


-- 
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: issues-unsubscribe@eventmesh.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [I] [Bug] Cluster-wide subscription discovery exposes only one subscriber per runtime (naming instance collision) (eventmesh)

Posted by "qqeasonchen (via GitHub)" <gi...@apache.org>.
qqeasonchen closed issue #5420: [Bug] Cluster-wide subscription discovery exposes only one subscriber per runtime (naming instance collision)
URL: https://github.com/apache/eventmesh/issues/5420


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org