Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4830f10

Browse files
committed
Disable vacuum's use of a buffer access strategy during failsafe
Traditionally, vacuum always makes use of a buffer access strategy 32buffers in size. This means that running vacuums tend not to cause toomany shared buffers to become dirty, however, this can cause vacuums torun much more slowly than they otherwise could as WAL flushes will occurmore frequently due to having to flush WAL out to the LSN of the dirtypage before that page can be written to disk.When we are performing failsafe VACUUMs (as added in1e55e7d), we reallywant to make the vacuum work go as quickly as possible, so here we disablethe buffer access strategy when entering failsafe mode while vacuuming arelation.Per idea and analyis from Andres Freund.In passing, also include some changes I had intended for32fbe02.Author: Melanie PlagemanReviewed-by: Justin Pryzby, David RowleyDiscussion:https://postgr.es/m/20230111182720.ejifsclfwymw2reb%40awork3.anarazel.de
1 parent525fb0a commit4830f10

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9320,8 +9320,12 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
93209320
</para>
93219321
<para>
93229322
When the failsafe is triggered, any cost-based delay that is
9323-
in effect will no longer be applied, and further non-essential
9324-
maintenance tasks (such as index vacuuming) are bypassed.
9323+
in effect will no longer be applied, further non-essential
9324+
maintenance tasks (such as index vacuuming) are bypassed, and any
9325+
<glossterm linkend="glossary-buffer-access-strategy">Buffer Access Strategy</glossterm>
9326+
in use will be disabled resulting in <command>VACUUM</command> being
9327+
free to make use of all of
9328+
<glossterm linkend="glossary-shared-memory">shared buffers</glossterm>.
93259329
</para>
93269330
<para>
93279331
The default is 1.6 billion transactions. Although users can

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,6 +2623,13 @@ lazy_check_wraparound_failsafe(LVRelState *vacrel)
26232623
{
26242624
vacrel->failsafe_active= true;
26252625

2626+
/*
2627+
* Abandon use of a buffer access strategy to allow use of all of
2628+
* shared buffers. We assume the caller who allocated the memory for
2629+
* the BufferAccessStrategy will free it.
2630+
*/
2631+
vacrel->bstrategy=NULL;
2632+
26262633
/* Disable index vacuuming, index cleanup, and heap rel truncation */
26272634
vacrel->do_index_vacuuming= false;
26282635
vacrel->do_index_cleanup= false;

‎src/backend/commands/vacuum.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,13 @@ vacuum(List *relations, VacuumParams *params,
391391

392392
/*
393393
* If caller didn't give us a buffer strategy object, make one in the
394-
* cross-transaction memory context.
394+
* cross-transaction memory context. We needn't bother making this for
395+
* VACUUM (FULL) or VACUUM (ONLY_DATABASE_STATS) as they'll not make use
396+
* of it.
395397
*/
396398
if (bstrategy==NULL&&
397-
!(params->options&VACOPT_ONLY_DATABASE_STATS||
398-
params->options&VACOPT_FULL))
399+
(params->options&(VACOPT_ONLY_DATABASE_STATS |
400+
VACOPT_FULL))==0)
399401
{
400402
MemoryContextold_context=MemoryContextSwitchTo(vac_context);
401403

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp