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

Commit 2767158

Browse files
committed
Prevent autovacuum transactions from running in serializable mode.
Force the transaction isolation level to READ COMMITTED in autovacuum worker and launcher processes. There is no benefit to using a higher isolation level, and doing so could result in delaying foreground transactions (or maybe even causing unnecessary serialization failures?). Noted by Dan Ports. Also, make sure we disable zero_damaged_pages and statement_timeout in the autovac launcher, not only workers. Now that the launcher can run transactions, these settings could affect its behavior, and it seems like the same arguments apply to the launcher as the workers.
1 parent 10ff8f9 commit 2767158

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/backend/postmaster/autovacuum.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,27 @@ AutoVacLauncherMain(int argc, char *argv[])
526526
/* must unblock signals before calling rebuild_database_list */
527527
PG_SETMASK(&UnBlockSig);
528528

529+
/*
530+
* Force zero_damaged_pages OFF in the autovac process, even if it is set
531+
* in postgresql.conf. We don't really want such a dangerous option being
532+
* applied non-interactively.
533+
*/
534+
SetConfigOption("zero_damaged_pages", "false", PGC_SUSET, PGC_S_OVERRIDE);
535+
536+
/*
537+
* Force statement_timeout to zero to avoid a timeout setting from
538+
* preventing regular maintenance from being executed.
539+
*/
540+
SetConfigOption("statement_timeout", "0", PGC_SUSET, PGC_S_OVERRIDE);
541+
542+
/*
543+
* Force default_transaction_isolation to READ COMMITTED. We don't
544+
* want to pay the overhead of serializable mode, nor add any risk
545+
* of causing deadlocks or delaying other transactions.
546+
*/
547+
SetConfigOption("default_transaction_isolation", "read committed",
548+
PGC_SUSET, PGC_S_OVERRIDE);
549+
529550
/* in emergency mode, just start a worker and go away */
530551
if (!AutoVacuumingActive())
531552
{
@@ -1527,13 +1548,22 @@ AutoVacWorkerMain(int argc, char *argv[])
15271548
*/
15281549
SetConfigOption("statement_timeout", "0", PGC_SUSET, PGC_S_OVERRIDE);
15291550

1551+
/*
1552+
* Force default_transaction_isolation to READ COMMITTED. We don't
1553+
* want to pay the overhead of serializable mode, nor add any risk
1554+
* of causing deadlocks or delaying other transactions.
1555+
*/
1556+
SetConfigOption("default_transaction_isolation", "read committed",
1557+
PGC_SUSET, PGC_S_OVERRIDE);
1558+
15301559
/*
15311560
* Force synchronous replication off to allow regular maintenance even if
15321561
* we are waiting for standbys to connect. This is important to ensure we
15331562
* aren't blocked from performing anti-wraparound tasks.
15341563
*/
15351564
if (synchronous_commit > SYNCHRONOUS_COMMIT_LOCAL_FLUSH)
1536-
SetConfigOption("synchronous_commit", "local", PGC_SUSET, PGC_S_OVERRIDE);
1565+
SetConfigOption("synchronous_commit", "local",
1566+
PGC_SUSET, PGC_S_OVERRIDE);
15371567

15381568
/*
15391569
* Get the info about the database we're going to work on.

0 commit comments

Comments
 (0)