PG19: use ShareUpdateExclusiveLock for REPACK CONCURRENTLY - #8805
Draft
ibrahim halatci (ihalatci) wants to merge 1 commit into
Draft
ibrahim halatci (ihalatci) wants to merge 1 commit into
ibrahim halatci (ihalatci) wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8805 +/- ##
==========================================
- Coverage 88.77% 88.77% -0.01%
==========================================
Files 290 290
Lines 65132 65133 +1
Branches 8223 8223
==========================================
- Hits 57823 57822 -1
+ Misses 4936 4935 -1
- Partials 2373 2376 +3 🚀 New features to boost your workflow:
|
This was referenced Sep 28, 2026
Contributor
Author
|
Beta 4 disposition: retained and still relevant. Please rebase onto current main and refresh the PG19 lock-contention regression; this PR should remain independent of the closed eager-aggregation stack. |
PreprocessClusterStmt resolved the target relation with
AccessExclusiveLock unconditionally. That is correct for CLUSTER and
for plain REPACK, but PostgreSQL deliberately runs REPACK
(CONCURRENTLY) under ShareUpdateExclusiveLock (RepackLockLevel() in
repack.c). Taking the stronger lock has two consequences:
* On a distributed table, a session holding only AccessShareLock
makes Citus block on AccessExclusiveLock, so the intended
"CONCURRENTLY is unsupported" error is masked by a lock wait.
* The lock is taken before the !IsCitusTable() early return and is
held until end of transaction, so on a plain local table the
repack decoding worker cannot lock the relation to export its
logical snapshot and the command waits forever on
RepackWorkerExport.
Resolve the relation with ShareUpdateExclusiveLock when CONCURRENTLY
is requested and keep AccessExclusiveLock for every other case, so
ordinary CLUSTER and REPACK locking is unchanged.
The unsupported-feature guard for distributed tables is retained; this
commit only stops it from being masked.
Add PG19-only regression coverage for both paths: a distributed table
whose rejection must not be masked by a concurrent reader, and a plain
local table whose REPACK (CONCURRENTLY) must complete.
Fixes #8756
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 61c1aeb4-1b56-4313-a35e-d65b59a557de
ibrahim halatci (ihalatci)
force-pushed
the
ihalatci-pg19-repack-lock-fix
branch
from
September 28, 2026 14:09
cc7c6a1 to
df2f245
Compare
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.
Draft fix for #8756.
This keeps Citus from taking AccessExclusiveLock before handing REPACK (CONCURRENTLY) to PostgreSQL. PostgreSQL uses ShareUpdateExclusiveLock for concurrent repack, and taking AEL in the Citus preprocessing path can block the repack worker even for local tables in a Citus database.
Stack: base PR.