@@ -190,6 +190,7 @@ typedef struct autovac_table
190
190
int at_vacuum_cost_delay ;
191
191
int at_vacuum_cost_limit ;
192
192
bool at_dobalance ;
193
+ bool at_sharedrel ;
193
194
char * at_relname ;
194
195
char * at_nspname ;
195
196
char * at_datname ;
@@ -203,6 +204,7 @@ typedef struct autovac_table
203
204
* wi_linksentry into free list or running list
204
205
* wi_dboidOID of the database this worker is supposed to work on
205
206
* wi_tableoidOID of the table currently being vacuumed, if any
207
+ * wi_sharedrelflag indicating whether table is marked relisshared
206
208
* wi_procpointer to PGPROC of the running worker, NULL if not started
207
209
* wi_launchtime Time at which this worker was launched
208
210
* wi_cost_*Vacuum cost-based delay parameters current in this worker
@@ -220,6 +222,7 @@ typedef struct WorkerInfoData
220
222
PGPROC * wi_proc ;
221
223
TimestampTz wi_launchtime ;
222
224
bool wi_dobalance ;
225
+ bool wi_sharedrel ;
223
226
int wi_cost_delay ;
224
227
int wi_cost_limit ;
225
228
int wi_cost_limit_base ;
@@ -717,6 +720,7 @@ AutoVacLauncherMain(int argc, char *argv[])
717
720
worker = AutoVacuumShmem -> av_startingWorker ;
718
721
worker -> wi_dboid = InvalidOid ;
719
722
worker -> wi_tableoid = InvalidOid ;
723
+ worker -> wi_sharedrel = false;
720
724
worker -> wi_proc = NULL ;
721
725
worker -> wi_launchtime = 0 ;
722
726
dlist_push_head (& AutoVacuumShmem -> av_freeWorkers ,
@@ -1683,6 +1687,7 @@ FreeWorkerInfo(int code, Datum arg)
1683
1687
dlist_delete (& MyWorkerInfo -> wi_links );
1684
1688
MyWorkerInfo -> wi_dboid = InvalidOid ;
1685
1689
MyWorkerInfo -> wi_tableoid = InvalidOid ;
1690
+ MyWorkerInfo -> wi_sharedrel = false;
1686
1691
MyWorkerInfo -> wi_proc = NULL ;
1687
1692
MyWorkerInfo -> wi_launchtime = 0 ;
1688
1693
MyWorkerInfo -> wi_dobalance = false;
@@ -2229,8 +2234,8 @@ do_autovacuum(void)
2229
2234
if (worker == MyWorkerInfo )
2230
2235
continue ;
2231
2236
2232
- /* ignore workers in other databases */
2233
- if (worker -> wi_dboid != MyDatabaseId )
2237
+ /* ignore workers in other databases(unless table is shared) */
2238
+ if (! worker -> wi_sharedrel && worker -> wi_dboid != MyDatabaseId )
2234
2239
continue ;
2235
2240
2236
2241
if (worker -> wi_tableoid == relid )
@@ -2271,6 +2276,7 @@ do_autovacuum(void)
2271
2276
* the lock so that other workers don't vacuum it concurrently.
2272
2277
*/
2273
2278
MyWorkerInfo -> wi_tableoid = relid ;
2279
+ MyWorkerInfo -> wi_sharedrel = tab -> at_sharedrel ;
2274
2280
LWLockRelease (AutovacuumScheduleLock );
2275
2281
2276
2282
/*
@@ -2382,6 +2388,7 @@ do_autovacuum(void)
2382
2388
*/
2383
2389
LWLockAcquire (AutovacuumLock ,LW_EXCLUSIVE );
2384
2390
MyWorkerInfo -> wi_tableoid = InvalidOid ;
2391
+ MyWorkerInfo -> wi_sharedrel = false;
2385
2392
LWLockRelease (AutovacuumLock );
2386
2393
2387
2394
/* restore vacuum cost GUCs for the next iteration */
@@ -2577,6 +2584,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
2577
2584
2578
2585
tab = palloc (sizeof (autovac_table ));
2579
2586
tab -> at_relid = relid ;
2587
+ tab -> at_sharedrel = classForm -> relisshared ;
2580
2588
tab -> at_vacoptions = VACOPT_SKIPTOAST |
2581
2589
(dovacuum ?VACOPT_VACUUM :0 ) |
2582
2590
(doanalyze ?VACOPT_ANALYZE :0 ) |