@ -180,6 +180,7 @@ typedef struct autovac_table
int at_vacuum_cost_limit ;
int at_vacuum_cost_limit ;
bool at_dobalance ;
bool at_dobalance ;
bool at_wraparound ;
bool at_wraparound ;
bool at_sharedrel ;
char * at_relname ;
char * at_relname ;
char * at_nspname ;
char * at_nspname ;
char * at_datname ;
char * at_datname ;
@ -193,6 +194,7 @@ typedef struct autovac_table
* wi_links entry into free list or running list
* wi_links entry into free list or running list
* wi_dboid OID of the database this worker is supposed to work on
* wi_dboid OID of the database this worker is supposed to work on
* wi_tableoid OID of the table currently being vacuumed , if any
* wi_tableoid OID of the table currently being vacuumed , if any
* wi_sharedrel flag indicating whether table is marked relisshared
* wi_proc pointer to PGPROC of the running worker , NULL if not started
* wi_proc pointer to PGPROC of the running worker , NULL if not started
* wi_launchtime Time at which this worker was launched
* wi_launchtime Time at which this worker was launched
* wi_cost_ * Vacuum cost - based delay parameters current in this worker
* wi_cost_ * Vacuum cost - based delay parameters current in this worker
@ -210,6 +212,7 @@ typedef struct WorkerInfoData
PGPROC * wi_proc ;
PGPROC * wi_proc ;
TimestampTz wi_launchtime ;
TimestampTz wi_launchtime ;
bool wi_dobalance ;
bool wi_dobalance ;
bool wi_sharedrel ;
int wi_cost_delay ;
int wi_cost_delay ;
int wi_cost_limit ;
int wi_cost_limit ;
int wi_cost_limit_base ;
int wi_cost_limit_base ;
@ -742,6 +745,7 @@ AutoVacLauncherMain(int argc, char *argv[])
worker = AutoVacuumShmem - > av_startingWorker ;
worker = AutoVacuumShmem - > av_startingWorker ;
worker - > wi_dboid = InvalidOid ;
worker - > wi_dboid = InvalidOid ;
worker - > wi_tableoid = InvalidOid ;
worker - > wi_tableoid = InvalidOid ;
worker - > wi_sharedrel = false ;
worker - > wi_proc = NULL ;
worker - > wi_proc = NULL ;
worker - > wi_launchtime = 0 ;
worker - > wi_launchtime = 0 ;
worker - > wi_links . next = ( SHM_QUEUE * ) AutoVacuumShmem - > av_freeWorkers ;
worker - > wi_links . next = ( SHM_QUEUE * ) AutoVacuumShmem - > av_freeWorkers ;
@ -1700,6 +1704,7 @@ FreeWorkerInfo(int code, Datum arg)
MyWorkerInfo - > wi_links . next = ( SHM_QUEUE * ) AutoVacuumShmem - > av_freeWorkers ;
MyWorkerInfo - > wi_links . next = ( SHM_QUEUE * ) AutoVacuumShmem - > av_freeWorkers ;
MyWorkerInfo - > wi_dboid = InvalidOid ;
MyWorkerInfo - > wi_dboid = InvalidOid ;
MyWorkerInfo - > wi_tableoid = InvalidOid ;
MyWorkerInfo - > wi_tableoid = InvalidOid ;
MyWorkerInfo - > wi_sharedrel = false ;
MyWorkerInfo - > wi_proc = NULL ;
MyWorkerInfo - > wi_proc = NULL ;
MyWorkerInfo - > wi_launchtime = 0 ;
MyWorkerInfo - > wi_launchtime = 0 ;
MyWorkerInfo - > wi_dobalance = false ;
MyWorkerInfo - > wi_dobalance = false ;
@ -2227,8 +2232,8 @@ do_autovacuum(void)
if ( worker = = MyWorkerInfo )
if ( worker = = MyWorkerInfo )
goto next_worker ;
goto next_worker ;
/* ignore workers in other databases */
/* ignore workers in other databases (unless table is shared) */
if ( worker - > wi_dboid ! = MyDatabaseId )
if ( ! worker - > wi_sharedrel & & worker - > wi_dboid ! = MyDatabaseId )
goto next_worker ;
goto next_worker ;
if ( worker - > wi_tableoid = = relid )
if ( worker - > wi_tableoid = = relid )
@ -2273,6 +2278,7 @@ do_autovacuum(void)
* the lock so that other workers don ' t vacuum it concurrently .
* the lock so that other workers don ' t vacuum it concurrently .
*/
*/
MyWorkerInfo - > wi_tableoid = relid ;
MyWorkerInfo - > wi_tableoid = relid ;
MyWorkerInfo - > wi_sharedrel = tab - > at_sharedrel ;
LWLockRelease ( AutovacuumScheduleLock ) ;
LWLockRelease ( AutovacuumScheduleLock ) ;
/*
/*
@ -2384,6 +2390,7 @@ deleted:
*/
*/
LWLockAcquire ( AutovacuumLock , LW_EXCLUSIVE ) ;
LWLockAcquire ( AutovacuumLock , LW_EXCLUSIVE ) ;
MyWorkerInfo - > wi_tableoid = InvalidOid ;
MyWorkerInfo - > wi_tableoid = InvalidOid ;
MyWorkerInfo - > wi_sharedrel = false ;
LWLockRelease ( AutovacuumLock ) ;
LWLockRelease ( AutovacuumLock ) ;
/* restore vacuum cost GUCs for the next iteration */
/* restore vacuum cost GUCs for the next iteration */
@ -2558,6 +2565,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
tab = palloc ( sizeof ( autovac_table ) ) ;
tab = palloc ( sizeof ( autovac_table ) ) ;
tab - > at_relid = relid ;
tab - > at_relid = relid ;
tab - > at_sharedrel = classForm - > relisshared ;
tab - > at_dovacuum = dovacuum ;
tab - > at_dovacuum = dovacuum ;
tab - > at_doanalyze = doanalyze ;
tab - > at_doanalyze = doanalyze ;
tab - > at_freeze_min_age = freeze_min_age ;
tab - > at_freeze_min_age = freeze_min_age ;