🌐 AI搜索 & 代理 主页
Skip to content

Commit 0839fbe

Browse files
committed
Correct comments of "Fix data loss at inplace update after heap_update()".
This corrects commit a07e03f. Reported-by: Paul A Jungwirth <pj@illuminatedcomputing.com> Reported-by: Surya Poondla <s_poondla@apple.com> Reviewed-by: Paul A Jungwirth <pj@illuminatedcomputing.com> Discussion: https://postgr.es/m/CA+renyWCW+_2QvXERBQ+mna6ANwAVXXmHKCA-WzL04bZRsjoBA@mail.gmail.com
1 parent 7db6809 commit 0839fbe

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/backend/access/heap/heapam.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6349,10 +6349,13 @@ heap_abort_speculative(Relation relation, const ItemPointerData *tid)
63496349
* Since this is intended for system catalogs and SERIALIZABLE doesn't cover
63506350
* DDL, this doesn't guarantee any particular predicate locking.
63516351
*
6352-
* One could modify this to return true for tuples with delete in progress,
6353-
* All inplace updaters take a lock that conflicts with DROP. If explicit
6354-
* "DELETE FROM pg_class" is in progress, we'll wait for it like we would an
6355-
* update.
6352+
* heap_delete() is a rarer source of blocking transactions (xwait). We'll
6353+
* wait for such a transaction just like for the normal heap_update() case.
6354+
* Normal concurrent DROP commands won't cause that, because all inplace
6355+
* updaters take some lock that conflicts with DROP. An explicit SQL "DELETE
6356+
* FROM pg_class" can cause it. By waiting, if the concurrent transaction
6357+
* executed both "DELETE FROM pg_class" and "INSERT INTO pg_class", our caller
6358+
* can find the successor tuple.
63566359
*
63576360
* Readers of inplace-updated fields expect changes to those fields are
63586361
* durable. For example, vac_truncate_clog() reads datfrozenxid from

src/backend/access/index/genam.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,11 @@ systable_endscan_ordered(SysScanDesc sysscan)
781781
* systable_inplace_update_begin --- update a row "in place" (overwrite it)
782782
*
783783
* Overwriting violates both MVCC and transactional safety, so the uses of
784-
* this function in Postgres are extremely limited. Nonetheless we find some
785-
* places to use it. See README.tuplock section "Locking to write
786-
* inplace-updated tables" and later sections for expectations of readers and
787-
* writers of a table that gets inplace updates. Standard flow:
784+
* this function in Postgres are extremely limited. This makes no effort to
785+
* support updating cache key columns or other indexed columns. Nonetheless
786+
* we find some places to use it. See README.tuplock section "Locking to
787+
* write inplace-updated tables" and later sections for expectations of
788+
* readers and writers of a table that gets inplace updates. Standard flow:
788789
*
789790
* ... [any slow preparation not requiring oldtup] ...
790791
* systable_inplace_update_begin([...], &tup, &inplace_state);

0 commit comments

Comments
 (0)