Skip to content

[Bugfix][TE] Roll back failed native notification setup - #4330

Open
waizuichougou wants to merge 1 commit into
kvcache-ai:mainfrom
waizuichougou:fix/rdma-endpoint-lifecycle-reclaim
Open

waizuichougou wants to merge 1 commit into
kvcache-ai:mainfrom
waizuichougou:fix/rdma-endpoint-lifecycle-reclaim

Conversation

@waizuichougou

@waizuichougou waizuichougou commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Summary

follow up #4214, when native RDMA notification setup was added without rollback for partial verbs
resource initialization.

Native RDMA notification setup can leave partially initialized verbs resources
behind when QP creation, QP initialization, MR registration, or receive WR
posting fails. These resources remain attached to the endpoint until endpoint
destruction, which can retain QPs, MRs, and buffers during repeated setup
failures.

This change adds rollback cleanup for failed notification construction and
verifies that the failure path releases all resources that were acquired.

Changes

  • Add rollback cleanup for partially initialized native notification state.
  • Release QPs, MRs, and host buffers on setup failure.
  • Preserve the original setup error code.
  • Add hardware-independent regression tests for successful rollback and failed
    cleanup retention.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake Conductor (mooncake-conductor)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Test commands:

cmake --build <build-dir> --target endpoint_store_test -j8
cmake --build <build-dir> --target rdma_native_notify_test -j8
endpoint_store_test --gtest_color=no
rdma_native_notify_test --gtest_color=no

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done: the native notification test binary was built and
    executed. Hardware-independent notification protocol tests passed; RDMA
    device-dependent cases were skipped when no usable RDMA device was present.

Results:

  • endpoint_store_test: 8/8 tests passed, including notification resource
    rollback and cleanup-failure retention cases.
  • rdma_native_notify_test: 2 tests passed; 16 RDMA-dependent tests skipped.

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

AI assistance was used for this contribution.

@he-yufeng he-yufeng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed line by line and ran the suite in the repo container (mc-dev:local, endpoint_store_test built from this head): 8/8 pass, including both new rollback tests; the EBUSY log lines in the retention test are the probes doing their job.

Mechanism checks beyond the suite:

  • Every failure site in constructNotification now rolls back (no notify CQ, QP create, QP INIT modify, MR reg, post-recv mid-loop), and the ordering is right: fail() records the error state first, then cleanup runs, so waiters wake into a coherent state.
  • The partial-failure semantics match the existing destructor philosophy: on cleanup error the resource stays tracked and enabled stays true, so ~RdmaEndPoint's retain-on-teardown-failure path still owns it.
  • Retry consistency holds: a later constructNotification() resets error/enabled at the top, so a fully rolled-back endpoint re-constructs cleanly.
  • Locking is sound: rollback runs inside the construct's notify_.mutex scope; the test peer takes the same lock for its probes.

One nit, not blocking: the tests drive rollbackNotificationConstruction directly through injected ops, so the wiring from each real failure site (that every s.fail path actually calls rollback) is read-verified only. Injecting a failing ibv_create_qp would cover that too, but the failure arms are simple enough that I would not gate on it.

Looks right to me.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants