mpcium icon indicating copy to clipboard operation
mpcium copied to clipboard

Dangling NATS Consumer Causes Client Not to Receive Result Event After Abnormal Exit

Open anhthii opened this issue 1 year ago • 0 comments

Dangling NATS Consumer Causes Client Not to Receive Result Event After Abnormal Exit

Description

When the mpcium-client sends an event (e.g., keygen request) to the MPCIUM cluster, it may fail to receive the corresponding result (e.g., mpc_keygen_result) if a previous session exited abnormally. This results in the NATS consumer (mpc_keygen_result) still showing Waiting Pulls: >0, even though the client is no longer running.

As a result, new instances of the client may not receive responses due to lingering/dangling pull requests.


Investigation

  • Stream: mpc
  • Consumer: mpc_keygen_result
  • nats consumer info showed:
    • Waiting Pulls: 3 of maximum 512
    • Unprocessed Messages: 0
  • No result was delivered to the new client instance.

After running:

nats consumer rm mpc mpc_keygen_result

Suggestions

Documentation:

  • Add this as a "Troubleshooting" entry in the docs.

  • Explain how to check Waiting Pulls and clean up dangling consumers.

Code Improvements:

  • Auto-detect and clean up orphaned consumers on client start.

  • Consider using ephemeral consumers or appending a unique instance ID to the consumer name.

  • Implement a client shutdown hook to remove the consumer cleanly.

anhthii avatar Jul 31 '25 02:07 anhthii