Skip to content

fix(#5359): wire DeliveryTopology + MetaStore into runtime boot; rollback on failure - #5370

Merged
qqeasonchen merged 1 commit into
developfrom
fix/5359-delivery-topology-wiring
Sep 8, 2026
Merged

fix(#5359): wire DeliveryTopology + MetaStore into runtime boot; rollback on failure#5370
qqeasonchen merged 1 commit into
developfrom
fix/5359-delivery-topology-wiring

Conversation

@qqeasonchen

Copy link
Copy Markdown
Contributor

What this PR does

Closes #5359 — Phase 1 wiring of the production-HA plan (#5354): close the divergent-ownership gap and make startup transactional.

1. The gap this fixes

EventMeshApplication.enableCluster built a PartitionOwnership state machine (Meta CAS + fencing) but never told the runtime — the pull loop kept its constructor-time topology (LOCAL_STICKY_PULL default) and polled every partition on every instance while the app layer believed ownership was exclusive. Two divergent ownership views; the cluster looked healthy but delivered duplicates.

2. Boot wiring

Change Effect
enableCluster now calls runtime.withClusterMeta(metaStore) + runtime.withTopology(PARTITION_OWNED_PULL) before runtime.start() The pull loop consults the same PartitionOwnership (ownedPartitions) the app built — one state machine, not two
UniRuntime.topology becomes volatile (flippable pre-start); new withTopology / withClusterMeta builders Post-start mutation fails fast (extends the #5356 fail-fast contract)
New topology() / clusterMeta() accessors Startup logging can report effective state

3. Startup transactionality

  • EventMeshApplication.start() wraps the whole boot in try/catch: on any failure it runs shutdown() (stop schedulers, release ports, release storage), attaches cleanup failures as suppressed, and rethrows — no more half-started processes holding the admin port.
  • Single-line effective-config log at startup (topology=… metaWired=… wsPort=… tls=…) so operators can audit a running deployment.

4. Tests (new EventMeshApplicationStartupTest, 4 cases)

  • enableClusterFlipsTopologyAndInjectsMeta — the core contract
  • topologyCannotFlipAfterStart / clusterMetaCannotChangeAfterStart — fail-fast guards
  • nullTopologyRejected

Local verification (Temurin 21.0.11): runtime tests + checkstyle (maxWarnings=0) all green.

Relations

Co-authored-by: qqeasonchen qqeasonchen@gmail.com

…back on failure

Phase 1 wiring of the production-HA plan (#5354), sub-issue #5359.

The gap: EventMeshApplication.enableCluster built a PartitionOwnership
state machine (Meta CAS + fencing) but never told the RUNTIME - the
pull loop kept its constructor-time topology (LOCAL_STICKY_PULL by
default) and polled every partition on every instance while the app
layer believed ownership was exclusive. Two divergent ownership views;
the cluster looked healthy but delivered duplicates.

Boot wiring:
- enableCluster now flips the runtime topology to PARTITION_OWNED_PULL
  and injects the shared MetaStore BEFORE runtime.start(), so the pull
  loop consults the same PartitionOwnership (ownedPartitions) the app
  built - one state machine, not two
- UniRuntime.topology becomes volatile (flippable pre-start); new
  withTopology / withClusterMeta builders reject post-start mutation
  (fail fast, like the #5356 contract); new topology() / clusterMeta()
  accessors

Startup transactionality (#5359):
- EventMeshApplication.start() wraps the whole boot in try/catch: on
  any failure it runs shutdown() (stop schedulers, release ports,
  release storage) with cleanup failures attached as suppressed, then
  rethrows - no more half-started processes holding the admin port
- single-line effective-config log at startup (topology / metaWired /
  wsPort / tls) so operators can audit a running deployment

Tests (new EventMeshApplicationStartupTest, 4 cases):
- enableCluster contract: topology flipped + shared meta injected
- withTopology / withClusterMeta fail fast after start
- null topology rejected
Local: runtime tests + checkstyle (maxWarnings=0) all green.

Refs #5359 (sub-issue of #5354).

Co-authored-by: qqeasonchen <qqeasonchen@gmail.com>
@qqeasonchen
qqeasonchen merged commit b3f9f75 into develop Sep 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P0] wire DeliveryTopology + MetaStore + FencingToken into UniRuntime boot (fail-fast)

1 participant