index cff6850ef86c6e3ea1c80a3cfa51e9b884d632e0..e118cecb9a43b9a87ad575ff385319c4ac0e6948 100644 (file)
@@ -812,7 +812,7 @@ ginInsertCleanup(GinState *ginstate, bool full_clean,
*/
LockPage(index, GIN_METAPAGE_BLKNO, ExclusiveLock);
workMemory =
- (IsAutoVacuumWorkerProcess() && autovacuum_work_mem != -1) ?
+ (AmAutoVacuumWorkerProcess() && autovacuum_work_mem != -1) ?
autovacuum_work_mem : maintenance_work_mem;
}
else
index aee6aab44ae2957ad6ca6a6e4a85cdd1efbe24f3..b3f415e2849a0b634c04bbd7a04173f1a4c5f242 100644 (file)
@@ -590,7 +590,7 @@ ginbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
/*
* and cleanup any pending inserts
*/
- ginInsertCleanup(&gvs.ginstate, !IsAutoVacuumWorkerProcess(),
+ ginInsertCleanup(&gvs.ginstate, !AmAutoVacuumWorkerProcess(),
false, true, stats);
}
@@ -701,7 +701,7 @@ ginvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
*/
if (info->analyze_only)
{
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
{
initGinState(&ginstate, index);
ginInsertCleanup(&ginstate, false, true, true, stats);
@@ -717,7 +717,7 @@ ginvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
{
stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
initGinState(&ginstate, index);
- ginInsertCleanup(&ginstate, !IsAutoVacuumWorkerProcess(),
+ ginInsertCleanup(&ginstate, !AmAutoVacuumWorkerProcess(),
false, true, stats);
}
index fa56480808bf3c728723015a4c884ed84fcb961a..5acea4a43a48076a951f7a1ec04cdfa668feeb8c 100644 (file)
@@ -307,7 +307,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params,
char **indnames = NULL;
verbose = (params->options & VACOPT_VERBOSE) != 0;
- instrument = (verbose || (IsAutoVacuumWorkerProcess() &&
+ instrument = (verbose || (AmAutoVacuumWorkerProcess() &&
params->log_min_duration >= 0));
if (instrument)
{
dead_items_max_items(LVRelState *vacrel)
{
int64 max_items;
- int vac_work_mem = IsAutoVacuumWorkerProcess() &&
+ int vac_work_mem = AmAutoVacuumWorkerProcess() &&
autovacuum_work_mem != -1 ?
autovacuum_work_mem : maintenance_work_mem;
index a03495d6c95ee11e0b4a6c4b47f106e08afb1919..d105d2fad7b7c323bcd3e74fbcce35aa3d3456c0 100644 (file)
@@ -351,7 +351,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
save_nestlevel = NewGUCNestLevel();
/* measure elapsed time iff autovacuum logging requires it */
- if (IsAutoVacuumWorkerProcess() && params->log_min_duration >= 0)
+ if (AmAutoVacuumWorkerProcess() && params->log_min_duration >= 0)
{
if (track_io_timing)
{
@@ -729,7 +729,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
vac_close_indexes(nindexes, Irel, NoLock);
/* Log the action if appropriate */
- if (IsAutoVacuumWorkerProcess() && params->log_min_duration >= 0)
+ if (AmAutoVacuumWorkerProcess() && params->log_min_duration >= 0)
{
TimestampTz endtime = GetCurrentTimestamp();
index 64da84862761eb4f74f3988f95a0c5f3a62e463b..e40cef6566ec380f956f004796552618f642b680 100644 (file)
@@ -564,7 +564,7 @@ vacuum(List *relations, VacuumParams *params, BufferAccessStrategy bstrategy,
else
{
Assert(params->options & VACOPT_ANALYZE);
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
use_own_xacts = true;
else if (in_outer_xact)
use_own_xacts = false;
@@ -809,7 +809,7 @@ vacuum_open_relation(Oid relid, RangeVar *relation, bits32 options,
* statements in the permission checks; otherwise, only log if the caller
* so requested.
*/
- if (!IsAutoVacuumWorkerProcess())
+ if (!AmAutoVacuumWorkerProcess())
elevel = WARNING;
else if (verbose)
elevel = LOG;
@@ -896,7 +896,7 @@ expand_vacuum_rel(VacuumRelation *vrel, MemoryContext vac_context,
* Since autovacuum workers supply OIDs when calling vacuum(), no
* autovacuum worker should reach this code.
*/
- Assert(!IsAutoVacuumWorkerProcess());
+ Assert(!AmAutoVacuumWorkerProcess());
/*
* We transiently take AccessShareLock to protect the syscache lookup
* [autovacuum_]vacuum_cost_delay to take effect while a table is being
* vacuumed or analyzed.
*/
- if (ConfigReloadPending && IsAutoVacuumWorkerProcess())
+ if (ConfigReloadPending && AmAutoVacuumWorkerProcess())
{
ConfigReloadPending = false;
ProcessConfigFile(PGC_SIGHUP);
index 2ab344c1f8ee42dd1c5ae1b84264d0b5fd73ca68..3ebe8e91a0b8f7fff82fcbdd142d3099ed5048dc 100644 (file)
#define MIN_AUTOVAC_SLEEPTIME 100.0 /* milliseconds */
#define MAX_AUTOVAC_SLEEPTIME 300 /* seconds */
-/* Flags to tell if we are in an autovacuum process */
-static bool am_autovacuum_launcher = false;
-static bool am_autovacuum_worker = false;
-
/*
* Variables to save the cost-related storage parameters for the current
* relation being vacuumed by this autovacuum worker. Using these, we can
@@ -436,8 +432,6 @@ AutoVacLauncherMain(int argc, char *argv[])
{
sigjmp_buf local_sigjmp_buf;
- am_autovacuum_launcher = true;
-
MyBackendType = B_AUTOVAC_LAUNCHER;
init_ps_display(NULL);
sigjmp_buf local_sigjmp_buf;
Oid dbid;
- am_autovacuum_worker = true;
-
MyBackendType = B_AUTOVAC_WORKER;
init_ps_display(NULL);
errhint("Enable the \"track_counts\" option.")));
}
-/*
- * IsAutoVacuum functions
- * Return whether this is either a launcher autovacuum process or a worker
- * process.
- */
-bool
-IsAutoVacuumLauncherProcess(void)
-{
- return am_autovacuum_launcher;
-}
-
-bool
-IsAutoVacuumWorkerProcess(void)
-{
- return am_autovacuum_worker;
-}
-
-
/*
* AutoVacuumShmemSize
* Compute space needed for autovacuum-related shared memory
index 67f92c24db128d0778176454d384f4bcdfa8d824..d8e89de7494c8ce3a70d9e28e2ad6d86c2a3f983 100644 (file)
if (worker == NULL)
elog(FATAL, "unable to find bgworker entry");
- IsBackgroundWorker = true;
-
MyBackendType = B_BG_WORKER;
init_ps_display(worker->bgw_name);
index cad5987bcbceb720bef0f4de6c39fb775b0c5a3e..59318067460ea29195489c19709b72e90168c867 100644 (file)
}
if (strcmp(argv[1], "--forkbgworker") == 0)
{
- /* do this as early as possible; in particular, before InitProcess() */
- IsBackgroundWorker = true;
-
/* Restore basic shared memory pointers */
InitShmemAccess(UsedShmemSegAddr);
index 8ecb85b86a3adf6300a1c3fa97085074a6a532e0..ad0fc6a04b6b32a84a4ec103fd253e71e3756684 100644 (file)
@@ -113,9 +113,6 @@ static long sleep_ms = MIN_SLOTSYNC_WORKER_NAPTIME_MS;
/* The restart interval for slot sync work used by postmaster */
#define SLOTSYNC_RESTART_INTERVAL_SEC 10
-/* Flag to tell if we are in a slot sync worker process */
-static bool am_slotsync_worker = false;
-
/*
* Flag to tell if we are syncing replication slots. Unlike the 'syncing' flag
* in SlotSyncCtxStruct, this flag is true only if the current process is
@@ -491,7 +488,7 @@ synchronize_one_slot(RemoteSlot *remote_slot, Oid remote_dbid)
latestFlushPtr = GetStandbyFlushRecPtr(NULL);
if (remote_slot->confirmed_lsn > latestFlushPtr)
{
- ereport(am_slotsync_worker ? LOG : ERROR,
+ ereport(AmLogicalSlotSyncWorkerProcess() ? LOG : ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("skipping slot synchronization as the received slot sync"
" LSN %X/%X for slot \"%s\" is ahead of the standby position %X/%X",
sigjmp_buf local_sigjmp_buf;
StringInfoData app_name;
- am_slotsync_worker = true;
-
MyBackendType = B_SLOTSYNC_WORKER;
init_ps_display(NULL);
return syncing_slots;
}
-/*
- * Is current process a slot sync worker?
- */
-bool
-IsLogicalSlotSyncWorker(void)
-{
- return am_slotsync_worker;
-}
-
/*
* Amount of shared memory required for slot synchronization.
*/
index c5461514d8f31228aa3865e0762fc93c0bdb7bfa..135151a272376b3488a53a86e3c5bd6b3477de78 100644 (file)
@@ -173,7 +173,7 @@ BuildRelationExtStatistics(Relation onerel, bool inh, double totalrows,
natts, vacattrstats);
if (!stats)
{
- if (!IsAutoVacuumWorkerProcess())
+ if (!AmAutoVacuumWorkerProcess())
ereport(WARNING,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("statistics object \"%s.%s\" could not be computed for relation \"%s.%s\"",
index 2681e4cdff5cbb51bfdc3e180742bc0521acbaaf..b06e4b845288e0f0f0a234a019e55c4be4f63fcf 100644 (file)
*/
char gprofDirName[32];
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
snprintf(gprofDirName, 32, "gprof/avworker");
else
snprintf(gprofDirName, 32, "gprof/%d", (int) getpid());
index 1867fff9cd80521b640345ca7761338ab5a546a3..1949d1496567ade0371625b02163fd6ee583f398 100644 (file)
#include "replication/slot.h"
#include "replication/slotsync.h"
#include "replication/syncrep.h"
-#include "replication/walsender.h"
#include "storage/condition_variable.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
elog(ERROR, "you already exist");
/* Decide which list should supply our PGPROC. */
- if (IsAnyAutoVacuumProcess())
+ if (AmAutoVacuumLauncherProcess() || AmAutoVacuumWorkerProcess())
procgloballist = &ProcGlobal->autovacFreeProcs;
- else if (IsBackgroundWorker)
+ else if (AmBackgroundWorkerProcess())
procgloballist = &ProcGlobal->bgworkerFreeProcs;
- else if (am_walsender)
+ else if (AmWalSenderProcess())
procgloballist = &ProcGlobal->walsenderFreeProcs;
else
procgloballist = &ProcGlobal->freeProcs;
* in the autovacuum case?
*/
SpinLockRelease(ProcStructLock);
- if (am_walsender)
+ if (AmWalSenderProcess())
ereport(FATAL,
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
errmsg("number of requested standby connections exceeds max_wal_senders (currently %d)",
* Slot sync worker also does not participate in it, see comments atop
* 'struct bkend' in postmaster.c.
*/
- if (IsUnderPostmaster && !IsAutoVacuumLauncherProcess() &&
- !IsLogicalSlotSyncWorker())
+ if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() &&
+ !AmLogicalSlotSyncWorkerProcess())
MarkPostmasterChildActive();
/*
MyProc->databaseId = InvalidOid;
MyProc->roleId = InvalidOid;
MyProc->tempNamespaceId = InvalidOid;
- MyProc->isBackgroundWorker = IsBackgroundWorker;
+ MyProc->isBackgroundWorker = AmBackgroundWorkerProcess();
MyProc->delayChkptFlags = 0;
MyProc->statusFlags = 0;
/* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
MyProc->statusFlags |= PROC_IS_AUTOVACUUM;
MyProc->lwWaiting = LW_WS_NOT_WAITING;
MyProc->lwWaitMode = 0;
MyProc->databaseId = InvalidOid;
MyProc->roleId = InvalidOid;
MyProc->tempNamespaceId = InvalidOid;
- MyProc->isBackgroundWorker = IsBackgroundWorker;
+ MyProc->isBackgroundWorker = AmBackgroundWorkerProcess();
MyProc->delayChkptFlags = 0;
MyProc->statusFlags = 0;
MyProc->lwWaiting = LW_WS_NOT_WAITING;
* Slot sync worker is also not a postmaster child, so skip this shared
* memory related processing here.
*/
- if (IsUnderPostmaster && !IsAutoVacuumLauncherProcess() &&
- !IsLogicalSlotSyncWorker())
+ if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() &&
+ !AmLogicalSlotSyncWorkerProcess())
MarkPostmasterChildInactive();
/* wake autovac launcher if needed -- see comments in FreeWorkerInfo */
index 59ab812d2e8ec6847d496c185f1ba0f9f24179d3..aec1b194424ff50b4d668ee35c1f0f8929095dcc 100644 (file)
ereport(FATAL,
(errcode(ERRCODE_QUERY_CANCELED),
errmsg("canceling authentication due to timeout")));
- else if (IsAutoVacuumWorkerProcess())
+ else if (AmAutoVacuumWorkerProcess())
ereport(FATAL,
(errcode(ERRCODE_ADMIN_SHUTDOWN),
errmsg("terminating autovacuum process due to administrator command")));
*/
proc_exit(1);
}
- else if (IsBackgroundWorker)
+ else if (AmBackgroundWorkerProcess())
ereport(FATAL,
(errcode(ERRCODE_ADMIN_SHUTDOWN),
errmsg("terminating background worker \"%s\" due to administrator command",
(errcode(ERRCODE_QUERY_CANCELED),
errmsg("canceling statement due to statement timeout")));
}
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
{
LockErrorCleanup();
ereport(ERROR,
index 111050725a6a0f2d122c389287175b2f09f52e46..b20a60b5a8790e18ebbcf79e38e8b2cbcbfabb85 100644 (file)
@@ -246,7 +246,7 @@ pgstat_report_vacuum(Oid tableoid, bool shared,
*/
tabentry->ins_since_vacuum = 0;
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
{
tabentry->last_autovacuum_time = ts;
tabentry->autovacuum_count++;
if (resetcounter)
tabentry->mod_since_analyze = 0;
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
{
tabentry->last_autoanalyze_time = GetCurrentTimestamp();
tabentry->autoanalyze_count++;
index aea95c8a69b658a6b30fe8043b6337016c474a1f..5b536ac50d135e963f5156fd593bb6f2733aa740 100644 (file)
bool IsPostmasterEnvironment = false;
bool IsUnderPostmaster = false;
bool IsBinaryUpgrade = false;
-bool IsBackgroundWorker = false;
bool ExitOnAnyError = false;
index 77fd80475638263b8f58c2d5976430b764aa2c1a..ad6ab45c6774aa6471fb0006cc502410ae06e4bf 100644 (file)
* This function should only be called in single-user mode, in autovacuum
* workers, in slot sync worker and in background workers.
*/
- Assert(!IsUnderPostmaster || IsAutoVacuumWorkerProcess() ||
- IsLogicalSlotSyncWorker() || IsBackgroundWorker);
+ Assert(!IsUnderPostmaster || AmAutoVacuumWorkerProcess() ||
+ AmLogicalSlotSyncWorkerProcess() || AmBackgroundWorkerProcess());
/* call only once */
Assert(!OidIsValid(AuthenticatedUserId));
index c49c048441b26f118ae88bb297b214e45c29503c..6a320aaedb7ada9b4a0aafd1484271b2007933f3 100644 (file)
@@ -346,7 +346,7 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
*
* We do not enforce them for autovacuum worker processes either.
*/
- if (IsUnderPostmaster && !IsAutoVacuumWorkerProcess())
+ if (IsUnderPostmaster && !AmAutoVacuumWorkerProcess())
{
/*
* Check that the database is currently allowing connections.
@@ -828,7 +828,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
before_shmem_exit(ShutdownPostgres, 0);
/* The autovacuum launcher is done here */
- if (IsAutoVacuumLauncherProcess())
+ if (AmAutoVacuumLauncherProcess())
{
/* report this backend in the PgBackendStatus array */
pgstat_bestart();
@@ -873,7 +873,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
* process, we use a fixed ID, otherwise we figure it out from the
* authenticated user name.
*/
- if (bootstrap || IsAutoVacuumWorkerProcess() || IsLogicalSlotSyncWorker())
+ if (bootstrap || AmAutoVacuumWorkerProcess() || AmLogicalSlotSyncWorkerProcess())
{
InitializeSessionUserIdStandalone();
am_superuser = true;
@@ -889,7 +889,7 @@ InitPostgres(const char *in_dbname, Oid dboid,
errhint("You should immediately run CREATE USER \"%s\" SUPERUSER;.",
username != NULL ? username : "postgres")));
}
- else if (IsBackgroundWorker)
+ else if (AmBackgroundWorkerProcess())
{
if (username == NULL && !OidIsValid(useroid))
{
index 712f4ad68a1d1f98eea47c56794743c292b11896..f900da61573176a69dd333fe7a877f2c14a01e27 100644 (file)
extern PGDLLIMPORT pid_t PostmasterPid;
extern PGDLLIMPORT bool IsPostmasterEnvironment;
extern PGDLLIMPORT bool IsUnderPostmaster;
-extern PGDLLIMPORT bool IsBackgroundWorker;
extern PGDLLIMPORT bool IsBinaryUpgrade;
extern PGDLLIMPORT bool ExitOnAnyError;
extern PGDLLIMPORT BackendType MyBackendType;
+#define AmAutoVacuumLauncherProcess() (MyBackendType == B_AUTOVAC_LAUNCHER)
+#define AmAutoVacuumWorkerProcess() (MyBackendType == B_AUTOVAC_WORKER)
+#define AmBackgroundWorkerProcess() (MyBackendType == B_BG_WORKER)
+#define AmWalSenderProcess() (MyBackendType == B_WAL_SENDER)
+#define AmLogicalSlotSyncWorkerProcess() (MyBackendType == B_SLOTSYNC_WORKER)
#define AmArchiverProcess() (MyBackendType == B_ARCHIVER)
#define AmBackgroundWriterProcess() (MyBackendType == B_BG_WRITER)
#define AmCheckpointerProcess() (MyBackendType == B_CHECKPOINTER)
index 1994aedef0320bce4645761b066d04472dc81f93..80cf4cdd969c76bdd3670d898dcbad9d50df313a 100644 (file)
@@ -49,11 +49,6 @@ extern PGDLLIMPORT int Log_autovacuum_min_duration;
/* Status inquiry functions */
extern bool AutoVacuumingActive(void);
-extern bool IsAutoVacuumLauncherProcess(void);
-extern bool IsAutoVacuumWorkerProcess(void);
-
-#define IsAnyAutoVacuumProcess() \
- (IsAutoVacuumLauncherProcess() || IsAutoVacuumWorkerProcess())
/* Functions to start autovacuum process, called from postmaster */
extern void autovac_init(void);
index 726d65f9b62d7b2971cb72ddc01dfb1172bc8ec6..dca57c502046d3dedd8e1efdf135148678529a6b 100644 (file)
@@ -34,7 +34,6 @@ extern int StartSlotSyncWorker(void);
extern void ShutDownSlotSync(void);
extern bool SlotSyncWorkerCanRestart(void);
extern bool IsSyncingReplicationSlots(void);
-extern bool IsLogicalSlotSyncWorker(void);
extern Size SlotSyncShmemSize(void);
extern void SlotSyncShmemInit(void);
extern void SyncReplicationSlots(WalReceiverConn *wrconn);