Repository navigation
Conversation
The reaper deletes stale and orphaned rows from llo_mercury_transmit_queue by inserted_at while the data-streams ORM's Delete removes them by transmission_hash. Run concurrently, the two can hold locks on rows the other wants and Postgres reports 40P01. Select the candidate rows with FOR UPDATE SKIP LOCKED. Reaping is best-effort, so skipping a row that is being deleted right now is fine; it is picked up by a later batch or the next reap cycle. Also bump chainlink-data-streams, which fixes the same pattern in Prune.
Contributor
|
Thank you for adding a CODEOWNERS file - @kalverra. |
kalverra
force-pushed
the
fix/llo-transmit-queue-deadlock
branch
from
October 30, 2026 16:49
974370f to
c82190d
Compare
kalverra
requested review from
AmrMohamedRezk,
KodeyThomas,
carte7000,
makramkd,
matYang,
ogtownsend and
tt-cll
October 30, 2026 16:49
product-security-plaid-production
Bot
requested review from
bolekk,
erikburt,
patrickhuie19 and
skudasov
October 30, 2026 16:49
product-security-plaid-production
Bot
requested review from
4of9,
DimitriosNaikopoulos,
akcll,
akuzni2 and
prashantkumar1982
October 30, 2026 16:49
Contributor
|
✅ No conflicts with other open PRs targeting |
Contributor
|
I see you updated files related to
|
|
This branch has not been deployed
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.
Problem
Postgres reports
40P01 deadlock detectedonllo_mercury_transmit_queueinside single LLO nodes. Three delete paths lock overlapping rows in different orders:Deleteinchainlink-data-streamsremoves rows bytransmission_hash(primary key order).Pruneinchainlink-data-streamswalks the oldest rows by(don_id, server_url, seq_nr).transmissionReaperdeletes byinserted_at(reapStale) or bydon_id(reapOrphaned).Run concurrently, any two of them can hold locks on rows the other wants, and Postgres kills one.
Deleteretries with backoff, so the damage is latency and flaky LLO tests rather than an outage.Fix
Select the reaper's candidate rows with
FOR UPDATE SKIP LOCKED. Reaping is best-effort, so skipping a row that is being deleted right now is fine; a later batch or the next reap cycle picks it up.This also bumps
chainlink-data-streamsto the commit that fixes the same pattern inPrune(smartcontractkit/chainlink-data-streams#281).Tests
Test_TransmissionReaper_SkipsRowsLockedByDeleteholds a row lock in one session and asserts the reaper returns without waiting, for both the stale and orphaned paths. Without the fix it fails with55P03 lock timeout.pgtest.NewIndependentSqlxSessionsso a test can hold locks on one real session while another contends for them.go test ./core/services/llo/ ./core/internal/testutils/pgtest/andgo test ./core/services/llo/ -race -run Test_TransmissionReaper -count=3pass.Notes
pre-pushhook was bypassed because it leaksGIT_DIRintotools/release/release-changelog/internal/enginetemp repos; those tests pass when run directly and are unrelated to this change.make test ARGS="diagnose --iterations 10 -- ./core/services/ocr2/plugins/llo/ -timeout 2m"should show zero40P01.