Skip to content

rdma_accept_handshake can panic via unreachable!() under simultaneous mutual handshake #402

Description

@xiaguan

Problem

PegaEngine::rdma_accept_handshake (pegaflow-core/src/lib.rs) does:

  1. invalidate_connection(client_addr) — tear down any stale connection
  2. get_or_prepare(client_addr) — expects Prepared, treats Existing as unreachable!("just invalidated connection")

Steps 1 and 2 take the backend lock separately. If two nodes handshake with each other simultaneously (exactly the deployment shape of the transfer-lock incident: peers booting together and cross-fetching), the local node's outbound complete_handshake_for can insert addr_connections[client_addr] in the window between the two calls. get_or_prepare then returns Existing and the unreachable! panics the gRPC handler.

Impact

Panic in the accept path; the peer's handshake fails and retries. Low probability per attempt but structurally reachable, and mutual-handshake bursts are the norm after a rolling restart.

Suggested fix

Replace the unreachable! with an error return (peer retries and then reuses the fresh connection), or make invalidate+prepare atomic under one lock.

Context

Flagged during the #399 review (pre-existing).

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions