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

Commit073afae

Browse files
author
Amit Kapila
committed
Avoid possible deadlock while locking multiple heap pages.
To avoid deadlock, backend acquires a lock on heap pages in blocknumber order. In certain cases, lock on heap pages is dropped andreacquired. In this case, the locks are dropped for reading incorresponding VM page/s. The issue is we re-acquire locks in bufferIdorder whereas the intention was to acquire in blockid order.This commit ensures that we will always acquire locks on heap pages inblockid order.Reported-by: Nishant FnuAuthor: Nishant FnuReviewed-by: Amit Kapila and Robert HaasBackpatch-through: 9.4Discussion:https://postgr.es/m/5883C831-2ED1-47C8-BFAC-2D5BAE5A8CAE@amazon.com
1 parent014763e commit073afae

File tree

1 file changed

+4
-4
lines changed
  • src/backend/access/heap

1 file changed

+4
-4
lines changed

‎src/backend/access/heap/hio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ ReadBufferBI(Relation relation, BlockNumber targetBlock,
115115
* visibility map page, if we haven't already got one.
116116
*
117117
* buffer2 may be InvalidBuffer, if only one buffer is involved. buffer1
118-
* must not be InvalidBuffer. If both buffers are specified,buffer1 must
119-
* be less thanbuffer2.
118+
* must not be InvalidBuffer. If both buffers are specified,block1 must
119+
* be less thanblock2.
120120
*/
121121
staticvoid
122122
GetVisibilityMapPins(Relationrelation,Bufferbuffer1,Bufferbuffer2,
@@ -127,7 +127,7 @@ GetVisibilityMapPins(Relation relation, Buffer buffer1, Buffer buffer2,
127127
boolneed_to_pin_buffer2;
128128

129129
Assert(BufferIsValid(buffer1));
130-
Assert(buffer2==InvalidBuffer||buffer1 <=buffer2);
130+
Assert(buffer2==InvalidBuffer||block1 <=block2);
131131

132132
while (1)
133133
{
@@ -449,7 +449,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
449449
* done a bit of extra work for no gain, but there's no real harm
450450
* done.
451451
*/
452-
if (otherBuffer==InvalidBuffer||buffer <=otherBuffer)
452+
if (otherBuffer==InvalidBuffer||targetBlock <=otherBlock)
453453
GetVisibilityMapPins(relation,buffer,otherBuffer,
454454
targetBlock,otherBlock,vmbuffer,
455455
vmbuffer_other);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp