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

Commitaa817c7

Browse files
committed
Avoid useless ReplicationOriginExitCleanup locking
When session_replication_state is NULL, we can know there's nothing todo with no lock acquisition. Do that.Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>Discussion:https://postgr.es/m/CALj2ACX+YaeRU5xJqR4C7kLsTO_F7DBRNF8WgeHvJZcKtNuK_A@mail.gmail.com
1 parent31acee4 commitaa817c7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎src/backend/replication/logical/origin.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ static ReplicationState *replication_states;
172172
staticReplicationStateCtl*replication_states_ctl;
173173

174174
/*
175-
* Backend-local, cached element from ReplicationState for use in a backend
176-
* replaying remote commits, so we don't have to search ReplicationState for
177-
* the backends current RepOriginId.
175+
* We keep a pointer to this backend's ReplicationState to avoid having to
176+
* search the replication_states array in replorigin_session_advance for each
177+
* remote commit. (Ownership of a backend's own entry can only be changed by
178+
* that backend.)
178179
*/
179180
staticReplicationState*session_replication_state=NULL;
180181

@@ -1056,10 +1057,12 @@ ReplicationOriginExitCleanup(int code, Datum arg)
10561057
{
10571058
ConditionVariable*cv=NULL;
10581059

1060+
if (session_replication_state==NULL)
1061+
return;
1062+
10591063
LWLockAcquire(ReplicationOriginLock,LW_EXCLUSIVE);
10601064

1061-
if (session_replication_state!=NULL&&
1062-
session_replication_state->acquired_by==MyProcPid)
1065+
if (session_replication_state->acquired_by==MyProcPid)
10631066
{
10641067
cv=&session_replication_state->origin_cv;
10651068

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp