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

Commite05f6f7

Browse files
Code cleanup in SyncRepWaitForLSN()
Commit14e8803 removed LWLocks when accessing MyProc->syncRepStatebut didn't clean up the surrounding code and comments.Cleanup and backpatch to 9.5, to keep code similar.Julien Rouhaud, improved by suggestion from Michael Paquier,implemented trivially by myself.
1 parent6e75559 commite05f6f7

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

‎src/backend/replication/syncrep.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,16 @@ SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
189189
*/
190190
for (;;)
191191
{
192-
intsyncRepState;
193-
194192
/* Must reset the latch before testing state. */
195193
ResetLatch(MyLatch);
196194

197195
/*
198-
* Try checking the state without the lock first. There's no
199-
* guarantee that we'll read the most up-to-date value, so if it looks
200-
* like we're still waiting, recheck while holding the lock. But if
201-
* it looks like we're done, we must really be done, because once
202-
* walsender changes the state to SYNC_REP_WAIT_COMPLETE, it will
203-
* never update it again, so we can't be seeing a stale value in that
204-
* case.
196+
* Acquiring the lock is not needed, the latch ensures proper barriers.
197+
* If it looks like we're done, we must really be done, because once
198+
* walsender changes the state to SYNC_REP_WAIT_COMPLETE, it will never
199+
* update it again, so we can't be seeing a stale value in that case.
205200
*/
206-
syncRepState=MyProc->syncRepState;
207-
if (syncRepState==SYNC_REP_WAITING)
208-
syncRepState=MyProc->syncRepState;
209-
if (syncRepState==SYNC_REP_WAIT_COMPLETE)
201+
if (MyProc->syncRepState==SYNC_REP_WAIT_COMPLETE)
210202
break;
211203

212204
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp