Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e2586c3

Browse files
committed
LockBuffer should not elog while holding buffer's cntx_lock.
1 parent 6adc255 commit e2586c3

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.101 2000/12/29 21:31:21 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.102 2001/01/08 18:31:49 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1977,7 +1977,10 @@ LockBuffer(Buffer buffer, int mode)
19771977
*buflock &= ~BL_W_LOCK;
19781978
}
19791979
else
1980+
{
1981+
S_UNLOCK(&(buf->cntx_lock));
19801982
elog(ERROR, "UNLockBuffer: buffer %lu is not locked", buffer);
1983+
}
19811984
}
19821985
else if (mode == BUFFER_LOCK_SHARE)
19831986
{
@@ -2033,7 +2036,10 @@ LockBuffer(Buffer buffer, int mode)
20332036
}
20342037
}
20352038
else
2039+
{
2040+
S_UNLOCK(&(buf->cntx_lock));
20362041
elog(ERROR, "LockBuffer: unknown lock mode %d", mode);
2042+
}
20372043

20382044
S_UNLOCK(&(buf->cntx_lock));
20392045
}
@@ -2122,11 +2128,11 @@ InitBufferIO(void)
21222128
#endif
21232129

21242130
/*
2131+
* Clean up any active buffer I/O after an error.
21252132
* This function is called from ProcReleaseSpins().
21262133
* BufMgrLock isn't held when this function is called.
2127-
* BM_IO_ERROR is always set. If BM_IO_ERROR was already
2128-
* set in case of output,this routine would kill all
2129-
* backends and reset postmaster.
2134+
*
2135+
* If I/O was in progress, BM_IO_ERROR is always set.
21302136
*/
21312137
void
21322138
AbortBufferIO(void)
@@ -2142,6 +2148,7 @@ AbortBufferIO(void)
21422148
else
21432149
{
21442150
Assert(buf->flags & BM_DIRTY || buf->cntxDirty);
2151+
/* Issue notice if this is not the first failure... */
21452152
if (buf->flags & BM_IO_ERROR)
21462153
{
21472154
elog(NOTICE, "write error may be permanent: cannot write block %u for %s/%s",

0 commit comments

Comments
 (0)