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

Commit 508a97e

Browse files
committed
Replace PGPROC.isBackgroundWorker with isRegularBackend.
Commit 34486b6 effectively redefined isBackgroundWorker as meaning "not a regular backend", whereas before it had the narrower meaning of AmBackgroundWorkerProcess(). For clarity, rename the field to isRegularBackend and invert its sense. Discussion: https://postgr.es/m/1808397.1735156190@sss.pgh.pa.us
1 parent 34486b6 commit 508a97e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/backend/access/transam/twophase.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
466466
proc->databaseId = databaseid;
467467
proc->roleId = owner;
468468
proc->tempNamespaceId = InvalidOid;
469-
proc->isBackgroundWorker = true;
469+
proc->isRegularBackend = false;
470470
proc->lwWaiting = LW_WS_NOT_WAITING;
471471
proc->lwWaitMode = 0;
472472
proc->waitLock = NULL;

src/backend/storage/ipc/procarray.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3640,8 +3640,8 @@ CountDBConnections(Oid databaseid)
36403640

36413641
if (proc->pid == 0)
36423642
continue; /* do not count prepared xacts */
3643-
if (proc->isBackgroundWorker)
3644-
continue; /* do not count background workers */
3643+
if (!proc->isRegularBackend)
3644+
continue; /* count only regular backend processes */
36453645
if (!OidIsValid(databaseid) ||
36463646
proc->databaseId == databaseid)
36473647
count++;
@@ -3712,8 +3712,8 @@ CountUserBackends(Oid roleid)
37123712

37133713
if (proc->pid == 0)
37143714
continue; /* do not count prepared xacts */
3715-
if (proc->isBackgroundWorker)
3716-
continue; /* do not count background workers */
3715+
if (!proc->isRegularBackend)
3716+
continue; /* count only regular backend processes */
37173717
if (proc->roleId == roleid)
37183718
count++;
37193719
}

src/backend/storage/lmgr/proc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ InitProcess(void)
432432
MyProc->databaseId = InvalidOid;
433433
MyProc->roleId = InvalidOid;
434434
MyProc->tempNamespaceId = InvalidOid;
435-
MyProc->isBackgroundWorker = !AmRegularBackendProcess();
435+
MyProc->isRegularBackend = AmRegularBackendProcess();
436436
MyProc->delayChkptFlags = 0;
437437
MyProc->statusFlags = 0;
438438
/* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */
@@ -631,7 +631,7 @@ InitAuxiliaryProcess(void)
631631
MyProc->databaseId = InvalidOid;
632632
MyProc->roleId = InvalidOid;
633633
MyProc->tempNamespaceId = InvalidOid;
634-
MyProc->isBackgroundWorker = true;
634+
MyProc->isRegularBackend = false;
635635
MyProc->delayChkptFlags = 0;
636636
MyProc->statusFlags = 0;
637637
MyProc->lwWaiting = LW_WS_NOT_WAITING;

src/include/storage/proc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ typedef enum
149149
* but its myProcLocks[] lists are valid.
150150
*
151151
* We allow many fields of this struct to be accessed without locks, such as
152-
* delayChkptFlags and isBackgroundWorker. However, keep in mind that writing
152+
* delayChkptFlags and isRegularBackend. However, keep in mind that writing
153153
* mirrored ones (see below) requires holding ProcArrayLock or XidGenLock in
154154
* at least shared mode, so that pgxactoff does not change concurrently.
155155
*
@@ -216,7 +216,7 @@ struct PGPROC
216216
Oid tempNamespaceId; /* OID of temp schema this backend is
217217
* using */
218218

219-
bool isBackgroundWorker; /* true if not a regular backend. */
219+
bool isRegularBackend; /* true if it's a regular backend. */
220220

221221
/*
222222
* While in hot standby mode, shows that a conflict signal has been sent

0 commit comments

Comments
 (0)