Skip to content

Conversation

@mkysel
Copy link
Collaborator

@mkysel mkysel commented Sep 29, 2025

Take a transaction-scoped advisory lock for identity update StoreLog under HA by calling queries.Queries.AdvisoryLockSequence and switching IdentityUpdateStorer.StoreLog to READ COMMITTED

  • Add a new SQLC query AdvisoryLockSequence in identity_updates.sql that invokes pg_advisory_xact_lock using a composite key of node_id and sequence_id.
  • Generate code in identity_updates.sql.go including queries.advisoryLockSequence SQL, queries.AdvisoryLockSequenceParams with NodeID and SequenceID, and queries.Queries.AdvisoryLockSequence method to execute the lock.
  • Update IdentityUpdateStorer.StoreLog in identity_update_storer.go to use sql.LevelReadCommitted, call querier.AdvisoryLockSequence with IDENTITY_UPDATE_ORIGINATOR_ID and msgSent.SequenceId, and return a non-recoverable error ErrAdvisoryLockSequence on lock failure.

📍Where to Start

Start with the transaction flow in IdentityUpdateStorer.StoreLog in identity_update_storer.go, then review the new SQLC query AdvisoryLockSequence in identity_updates.sql and its generated method in identity_updates.sql.go.

Changes since #1184 opened

  • Renamed SQL advisory lock query and generated code from sequence-based to identity-update-specific naming [79cb8de]
  • Updated advisory lock method calls in identity update processing [79cb8de]

Macroscope summarized 79cb8de.

@mkysel mkysel requested a review from a team as a code owner September 29, 2025 15:29
@graphite-app
Copy link

graphite-app bot commented Sep 29, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@mkysel mkysel linked an issue Sep 29, 2025 that may be closed by this pull request
@mkysel mkysel requested review from a team and neekolas September 30, 2025 17:16
@mkysel mkysel merged commit f37bdc3 into main Oct 1, 2025
11 checks passed
@mkysel mkysel deleted the mkysel/fix-StoreLog branch October 1, 2025 13:09
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.

Investigate InsertAddressLog enhancements

4 participants