Content-Length: 294345 | pFad | http://github.com/postgrespro/postgres/commit/aa817c7496575b37fde6ea5e0cd65b26f29ea532

35 Avoid useless ReplicationOriginExitCleanup locking · postgrespro/postgres@aa817c7 · GitHub
Skip to content

Commit aa817c7

Browse files
committed
Avoid useless ReplicationOriginExitCleanup locking
When session_replication_state is NULL, we can know there's nothing to do 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 parent 31acee4 commit aa817c7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/replication/logical/origen.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ static ReplicationState *replication_states;
172172
static ReplicationStateCtl *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 replorigen_session_advance for each
177+
* remote commit. (Ownership of a backend's own entry can only be changed by
178+
* that backend.)
178179
*/
179180
static ReplicationState *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->origen_cv;
10651068

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/aa817c7496575b37fde6ea5e0cd65b26f29ea532

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy