diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 86a3b3d8be..406c588a1d 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -662,7 +662,7 @@ AutoVacLauncherMain(int argc, char *argv[]) */ (void) WaitLatch(MyLatch, WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH, - (nap.tv_sec * 1000L) + (nap.tv_usec / 1000L), + 100L, WAIT_EVENT_AUTOVACUUM_MAIN); ResetLatch(MyLatch); @@ -769,6 +769,9 @@ AutoVacLauncherMain(int argc, char *argv[]) } LWLockRelease(AutovacuumLock); /* either shared or exclusive */ + /* force launch */ + can_launch = true; + /* if we can't do anything, just go back to sleep */ if (!can_launch) continue; @@ -1267,38 +1270,6 @@ do_start_worker(void) if (!tmp->adw_entry) continue; - /* - * Also, skip a database that appears on the database list as having - * been processed recently (less than autovacuum_naptime seconds ago). - * We do this so that we don't select a database which we just - * selected, but that pgstat hasn't gotten around to updating the last - * autovacuum time yet. - */ - skipit = false; - - dlist_reverse_foreach(iter, &DatabaseList) - { - avl_dbase *dbp = dlist_container(avl_dbase, adl_node, iter.cur); - - if (dbp->adl_datid == tmp->adw_datid) - { - /* - * Skip this database if its next_worker value falls between - * the current time and the current time plus naptime. - */ - if (!TimestampDifferenceExceeds(dbp->adl_next_worker, - current_time, 0) && - !TimestampDifferenceExceeds(current_time, - dbp->adl_next_worker, - autovacuum_naptime * 1000)) - skipit = true; - - break; - } - } - if (skipit) - continue; - /* * Remember the db with oldest autovac time. (If we are here, both * tmp->entry and db->entry must be non-null.) @@ -3198,6 +3169,9 @@ relation_needs_vacanalyze(Oid relid, /* ANALYZE refuses to work with pg_statistic */ if (relid == StatisticRelationId) *doanalyze = false; + + *dovacuum = true; + *doanalyze = true; } /* diff --git a/src/bin/pg_upgrade/t/003_logical_slots.pl b/src/bin/pg_upgrade/t/003_logical_slots.pl index 5b01cf8c40..5c181375a4 100644 --- a/src/bin/pg_upgrade/t/003_logical_slots.pl +++ b/src/bin/pg_upgrade/t/003_logical_slots.pl @@ -17,6 +17,7 @@ my $mode = $ENV{PG_TEST_PG_UPGRADE_MODE} || '--copy'; # Initialize old cluster my $oldpub = PostgreSQL::Test::Cluster->new('oldpub'); $oldpub->init(allows_streaming => 'logical'); +$oldpub->append_conf('postgresql.conf', 'autovacuum_naptime = 3'); # Initialize new cluster my $newpub = PostgreSQL::Test::Cluster->new('newpub'); @@ -164,6 +165,7 @@ $sub->wait_for_subscription_sync($oldpub, 'regress_sub'); # 2. Temporarily disable the subscription $sub->safe_psql('postgres', "ALTER SUBSCRIPTION regress_sub DISABLE"); +sleep 4; $oldpub->stop; # pg_upgrade should be successful