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

Commit3b79cc0

Browse files
committed
Removed bad Assert(!buf->ri_lock) when unlocking exclusively
locked buffer.
1 parent4ca7b4d commit3b79cc0

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.54 1999/06/10 14:17:09 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.55 1999/06/11 09:00:02 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1960,7 +1960,12 @@ UnlockBuffers()
19601960
}
19611961
if (BufferLocks[i]&BL_RI_LOCK)
19621962
{
1963-
Assert(buf->ri_lock);
1963+
/*
1964+
* Someone else could remove our RI lock when acquiring
1965+
* W lock. This is possible if we came here from elog(ERROR)
1966+
* from IpcSemaphore{Lock|Unlock}(WaitCLSemId). And so we
1967+
* don't do Assert(buf->ri_lock) here.
1968+
*/
19641969
buf->ri_lock= false;
19651970
}
19661971
if (BufferLocks[i]&BL_W_LOCK)
@@ -2008,7 +2013,6 @@ LockBuffer(Buffer buffer, int mode)
20082013
{
20092014
Assert(buf->w_lock);
20102015
Assert(buf->r_locks==0);
2011-
Assert(!buf->ri_lock);
20122016
Assert(!(BufferLocks[buffer-1]& (BL_R_LOCK |BL_RI_LOCK)))
20132017
buf->w_lock= false;
20142018
BufferLocks[buffer-1] &= ~BL_W_LOCK;
@@ -2043,10 +2047,15 @@ LockBuffer(Buffer buffer, int mode)
20432047
Assert(!(BufferLocks[buffer-1]& (BL_R_LOCK |BL_W_LOCK |BL_RI_LOCK)));
20442048
while (buf->r_locks>0||buf->w_lock)
20452049
{
2046-
if (buf->r_locks>3)
2050+
if (buf->r_locks>3|| (BufferLocks[buffer-1]&BL_RI_LOCK))
20472051
{
2048-
if (!(BufferLocks[buffer-1]&BL_RI_LOCK))
2049-
BufferLocks[buffer-1] |=BL_RI_LOCK;
2052+
/*
2053+
* Our RI lock might be removed by concurrent W lock
2054+
* acquiring (see what we do with RI locks below
2055+
* when our own W acquiring succeeded) and so
2056+
* we set RI lock again if we already did this.
2057+
*/
2058+
BufferLocks[buffer-1] |=BL_RI_LOCK;
20502059
buf->ri_lock= true;
20512060
}
20522061
#ifdefHAS_TEST_AND_SET
@@ -2063,6 +2072,10 @@ LockBuffer(Buffer buffer, int mode)
20632072
BufferLocks[buffer-1] |=BL_W_LOCK;
20642073
if (BufferLocks[buffer-1]&BL_RI_LOCK)
20652074
{
2075+
/*
2076+
* It's possible to remove RI locks acquired by another
2077+
* W lockers here, but they'll take care about it.
2078+
*/
20662079
buf->ri_lock= false;
20672080
BufferLocks[buffer-1] &= ~BL_RI_LOCK;
20682081
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp