Skip to content

Add random wait time to aborted join retry - #63

Open
niecore wants to merge 1 commit into
esl:mainfrom
niecore:random-wait-in-lock
Open

Add random wait time to aborted join retry#63
niecore wants to merge 1 commit into
esl:mainfrom
niecore:random-wait-in-lock

Conversation

@niecore

@niecore niecore commented Jul 29, 2026

Copy link
Copy Markdown

Avoid a deadlock when multiple nodes request the global lock at the same time: global:trans/4 is called with zero retries, so when several nodes each grab the lock on part of the cluster, the transaction is aborted on all of them and every node retries immediately in lockstep, colliding again and again.

Sleeping for a random 1-3000 ms before retrying desynchronizes the nodes so that one of them can acquire the lock on all nodes and the joins proceed one after another.

This issue was observed by running @mongoose-im in CETS cluster and adding the 7th or 8th node:

When the new node connected, the CETS discovery process on every node simultaneously tried to join each of replicated tables with it. Every join must first acquire a single cluster-wide lock via global:trans — with Retries = 0 (one shot: grants needed from all nodes, any collision aborts) and an immediate retry loop with no backoff in cets_join:join_loop.

Avoid a deadlock when multiple nodes request the global lock at the
same time: global:trans/4 is called with zero retries, so when several
nodes each grab the lock on part of the cluster, the transaction is
aborted on all of them and every node retries immediately in lockstep,
colliding again and again.

Sleeping for a random 1-3000 ms before retrying desynchronizes the
nodes so that one of them can acquire the lock on all nodes and the
joins proceed one after another.

Verified with cets_join_SUITE (join_retried_if_lock_is_busy covers the
aborted-retry path); results match the parent commit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant