Content-Length: 294679 | pFad | http://github.com/postgrespro/postgres/commit/e629a01f6973688f77ecff964d9d6bea9bc4b374

01 During heap rebuild, lock any TOAST index until end of transaction. · postgrespro/postgres@e629a01 · GitHub
Skip to content

Commit e629a01

Browse files
committed
During heap rebuild, lock any TOAST index until end of transaction.
swap_relation_files() calls toast_get_valid_index() to find and lock this index, just before swapping with the rebuilt TOAST index. The latter function releases the lock before returning. Potential for mischief is low; a concurrent session can issue ALTER INDEX ... SET (fillfactor = ...), which is not alarming. Nonetheless, changing pg_class.relfilenode without a lock is unconventional. Back-patch to 9.5 (all supported versions), because another fix needs this. Discussion: https://postgr.es/m/20191226001521.GA1772687@rfd.leadboat.com
1 parent d60ef94 commit e629a01

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/backend/access/common/toast_internals.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ toast_get_valid_index(Oid toastoid, LOCKMODE lock)
528528
validIndexOid = RelationGetRelid(toastidxs[validIndex]);
529529

530530
/* Close the toast relation and all its indexes */
531-
toast_close_indexes(toastidxs, num_indexes, lock);
532-
table_close(toastrel, lock);
531+
toast_close_indexes(toastidxs, num_indexes, NoLock);
532+
table_close(toastrel, NoLock);
533533

534534
return validIndexOid;
535535
}

src/backend/commands/cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap,
14891489

14901490
/* Get the associated valid index to be renamed */
14911491
toastidx = toast_get_valid_index(newrel->rd_rel->reltoastrelid,
1492-
AccessShareLock);
1492+
NoLock);
14931493

14941494
/* rename the toast table ... */
14951495
snprintf(NewToastName, NAMEDATALEN, "pg_toast_%u",

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/e629a01f6973688f77ecff964d9d6bea9bc4b374

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy