=== Applying patches on top of PostgreSQL commit ID 9526a195492ce907c8813b85ddc9c0588bd27d6c === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Mon Nov 30 08:50:30 UTC 2026 On branch cf/7369 nothing to commit, working tree clean === using 'git am' to apply patch ./0001-Limit-the-time-for-REPACK-CONCURRENTLY-to-stay-in-th.patch === Applying: Limit the time for REPACK (CONCURRENTLY) to stay in the lock queue. Using index info to reconstruct a base tree... M src/backend/commands/repack.c Falling back to patching base and 3-way merge... Auto-merging src/backend/commands/repack.c CONFLICT (content): Merge conflict in src/backend/commands/repack.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Limit the time for REPACK (CONCURRENTLY) to stay in the lock queue. When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./0001-Limit-the-time-for-REPACK-CONCURRENTLY-to-stay-in-th.patch === patching file src/backend/commands/repack.c Hunk #1 FAILED at 212. Hunk #2 succeeded at 3512 (offset 40 lines). Hunk #3 succeeded at 3635 with fuzz 2 (offset 40 lines). 1 out of 3 hunks FAILED -- saving rejects to file src/backend/commands/repack.c.rej Unstaged changes after reset: M src/backend/commands/repack.c Removing src/backend/commands/repack.c.rej === using 'git apply' to apply patch ./0001-Limit-the-time-for-REPACK-CONCURRENTLY-to-stay-in-th.patch === Applied patch to 'src/backend/commands/repack.c' with conflicts. U src/backend/commands/repack.c diff --cc src/backend/commands/repack.c index eee8b646029,49516d0a637..00000000000 --- a/src/backend/commands/repack.c +++ b/src/backend/commands/repack.c @@@ -213,7 -212,9 +213,13 @@@ static void rebuild_relation_finish_con Oid identIdx, TransactionId frozenXid, MultiXactId cutoffMulti); ++<<<<<<< ours +static List *build_new_indexes(Relation NewHeap, List *OldIndexes); ++======= + static void lock_relation_with_timeout(Oid relid, int timeout, + ChangeContext *chgcxt); + static List *build_new_indexes(Relation NewHeap, Relation OldHeap, List *OldIndexes); ++>>>>>>> theirs static void copy_index_constraints(Relation old_index, Oid new_index_id, Oid new_heap_id); static void copy_attribute_defaults(Oid old_heap_oid, Oid new_heap_oid); @@@ -3632,10 -3598,74 +3642,78 @@@ rebuild_relation_finish_concurrent(Rela } /* ++<<<<<<< ours + * Build indexes on NewHeap according to those on the old heap. ++======= + * Lock relation with AccessExclusiveLock, but never wait longer than + * 'timeout' milliseconds. + */ + static void + lock_relation_with_timeout(Oid relid, int timeout, ChangeContext *chgcxt) + { + int LockTimeout_save; + MemoryContext edata_context, oldcxt; + XLogRecPtr end_of_wal; + + edata_context = AllocSetContextCreate(TopTransactionContext, + "RepackLockError", + ALLOCSET_DEFAULT_SIZES); + oldcxt = CurrentMemoryContext; + while (true) + { + bool acquired = false; + + LockTimeout_save = LockTimeout; + LockTimeout = timeout; + + PG_TRY(); + { + LockRelationOid(relid, AccessExclusiveLock); + + acquired = true; + } + PG_CATCH(); + { + ErrorData *edata; + + LockTimeout = LockTimeout_save; + + /* Save error info in caller's context */ + MemoryContextSwitchTo(edata_context); + edata = CopyErrorData(); + FlushErrorState(); + MemoryContextSwitchTo(oldcxt); + + /* + * LOCK_NOT_AVAILABLE is what we expect on timeout, anything else + * is worth re-throwing. + */ + if (edata->sqlerrcode != ERRCODE_LOCK_NOT_AVAILABLE) + ReThrowError(edata); + MemoryContextReset(edata_context); + } + PG_END_TRY(); + LockTimeout = LockTimeout_save; + + if (acquired) + goto out; + + /* Process the data changes that appeared during the waiting. */ + XLogFlush(GetXLogInsertEndRecPtr()); + end_of_wal = GetFlushRecPtr(NULL); + process_concurrent_changes(end_of_wal, chgcxt, false); + } + + out: + MemoryContextDelete(edata_context); + } + + /* + * Build indexes on NewHeap according to those on OldHeap. ++>>>>>>> theirs * - * OldIndexes is the list of index OIDs on OldHeap. The contained indexes end - * up locked using ShareUpdateExclusiveLock. + * OldIndexes is the list of index OIDs on the old heap. The contained indexes + * end up locked using ShareUpdateExclusiveLock. * * A list of OIDs of the corresponding indexes created on NewHeap is * returned. The order of items does match, so we can use these arrays to swap