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

Commitf6ff75f

Browse files
committed
Make BufferIsExclusiveLocked and BufferIsDirty work for local buffers.
These functions tried to check the state of the buffer's content lockeven for local buffers. Since we don't use the content lock for alocal buffer, that would lead to a "false" result fromLWLockHeldByMeInMode, which would mean a misleading "false" answerfrom BufferIsExclusiveLocked (we'd rather that case always return"true") or an assertion failure in BufferIsDirty.The core code never applies these two functions to local buffers,and apparently no extensions do either, since we've not heardcomplaints. Still, in the name of future-proofing, let's fixthem to act as though a pinned local buffer is content-locked.Author: Srinath Reddy <srinath2133@gmail.com>Discussion:https://postgr.es/m/19396ef77f8.1098c4a1810508.2255483659262451647@zohocorp.com
1 parent128897b commitf6ff75f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,20 +2472,19 @@ BufferIsExclusiveLocked(Buffer buffer)
24722472
{
24732473
BufferDesc*bufHdr;
24742474

2475+
Assert(BufferIsPinned(buffer));
2476+
24752477
if (BufferIsLocal(buffer))
24762478
{
2477-
intbufid=-buffer-1;
2478-
2479-
bufHdr=GetLocalBufferDescriptor(bufid);
2479+
/* Content locks are not maintained for local buffers. */
2480+
return true;
24802481
}
24812482
else
24822483
{
24832484
bufHdr=GetBufferDescriptor(buffer-1);
2485+
returnLWLockHeldByMeInMode(BufferDescriptorGetContentLock(bufHdr),
2486+
LW_EXCLUSIVE);
24842487
}
2485-
2486-
Assert(BufferIsPinned(buffer));
2487-
returnLWLockHeldByMeInMode(BufferDescriptorGetContentLock(bufHdr),
2488-
LW_EXCLUSIVE);
24892488
}
24902489

24912490
/*
@@ -2501,21 +2500,22 @@ BufferIsDirty(Buffer buffer)
25012500
{
25022501
BufferDesc*bufHdr;
25032502

2503+
Assert(BufferIsPinned(buffer));
2504+
25042505
if (BufferIsLocal(buffer))
25052506
{
25062507
intbufid=-buffer-1;
25072508

25082509
bufHdr=GetLocalBufferDescriptor(bufid);
2510+
/* Content locks are not maintained for local buffers. */
25092511
}
25102512
else
25112513
{
25122514
bufHdr=GetBufferDescriptor(buffer-1);
2515+
Assert(LWLockHeldByMeInMode(BufferDescriptorGetContentLock(bufHdr),
2516+
LW_EXCLUSIVE));
25132517
}
25142518

2515-
Assert(BufferIsPinned(buffer));
2516-
Assert(LWLockHeldByMeInMode(BufferDescriptorGetContentLock(bufHdr),
2517-
LW_EXCLUSIVE));
2518-
25192519
returnpg_atomic_read_u32(&bufHdr->state)&BM_DIRTY;
25202520
}
25212521

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp