Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfdcee9f

Browse files
committed
Avoid testing tuple visibility without buffer lock.
INSERT ... ON CONFLICT (specifically ExecCheckHeapTupleVisible) containsanother example of this unsafe coding practice. It is much harder to geta failure out of it than the case fixed in commit6292c23, because inmost scenarios any hint bits that could be set would have already been setearlier in the command. However, Konstantin Knizhnik reported a failurewith a custom transaction manager, and it's clearly possible to get afailure via a race condition in async-commit mode.For lack of a reproducible example, no regression test case in thiscommit.I did some testing with Asserts added to tqual.c's functions, and can saythat running "make check-world" exposed these two bugs and no others.The Asserts are messy enough that I've not added them to the code for now.Report: <57EE93C8.8080504@postgrespro.ru>Related-Discussion: <CAO3NbwOycQjt2Oqy2VW-eLTq2M5uGMyHnGm=RNga4mjqcYD7gQ@mail.gmail.com>
1 parentc4016fc commitfdcee9f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎src/backend/executor/nodeModifyTable.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ ExecCheckHeapTupleVisible(EState *estate,
194194
if (!IsolationUsesXactSnapshot())
195195
return;
196196

197+
/*
198+
* We need buffer pin and lock to call HeapTupleSatisfiesVisibility.
199+
* Caller should be holding pin, but not lock.
200+
*/
201+
LockBuffer(buffer,BUFFER_LOCK_SHARE);
197202
if (!HeapTupleSatisfiesVisibility(tuple,estate->es_snapshot,buffer))
198203
{
199204
/*
@@ -207,6 +212,7 @@ ExecCheckHeapTupleVisible(EState *estate,
207212
(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
208213
errmsg("could not serialize access due to concurrent update")));
209214
}
215+
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
210216
}
211217

212218
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp