fix(event-indexer): remove non-functional advisory lock from leader election - #1295
Open
colemaya95-ctrl wants to merge 1 commit into
Open
Conversation
…lection The PostgreSQL advisory lock was held only for the duration of the database connection, not for the duration of leadership. Each call to try_acquire_inner() obtained a connection from the shared pool and returned it immediately, releasing the advisory lock before the next heartbeat. This made the 'second layer of mutual exclusion' documentation inaccurate and ineffective. The row-level lease via INSERT...ON CONFLICT DO UPDATE is sufficient for atomic leader election. When the lease acquisition succeeds, the row is atomic at the database level, eliminating the split-brain race condition that the advisory lock was intended to prevent. This commit: - Removes the advisory lock acquisition and release code - Removes the LOCK_KEY constant - Updates module documentation to accurately describe the row-level lease - Removes unused imports and variables Closes StellarCheckMate#1276
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The PostgreSQL advisory lock was held only for the duration of the database connection, not for the duration of leadership. Each call to
try_acquire_inner()obtained a connection from the shared pool and returned it immediately, releasing the advisory lock before the next heartbeat. This made the 'second layer of mutual exclusion' documentation inaccurate and ineffective.The row-level lease via
INSERT...ON CONFLICT DO UPDATEis sufficient for atomic leader election. When the lease acquisition succeeds, the row is atomic at the database level, eliminating the split-brain race condition that the advisory lock was intended to prevent.Changes
LOCK_KEYconstantdebug) and variables (ttl_interval)try_acquire_innerandreleaseTesting
cargo fmt)CI Status
The fix passes all local checks that match the CI pipeline:
Closes #1276