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

Commit88dd4b0

Browse files
committed
Reduce the acceptable staleness of pgstat data for autovacuum, per the
longstanding note in the source that this patch removes.
1 parentb8fab24 commit88dd4b0

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
*
5656
*
5757
* IDENTIFICATION
58-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.85 2008/11/02 21:24:52 tgl Exp $
58+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.86 2008/11/03 19:03:41 alvherre Exp $
5959
*
6060
*-------------------------------------------------------------------------
6161
*/
@@ -2149,8 +2149,10 @@ do_autovacuum(void)
21492149
* It could have changed if something else processed the table while
21502150
* we weren't looking.
21512151
*
2152-
* FIXME we ignore the possibility that the table was finished being
2153-
* vacuumed in the last 500ms (PGSTAT_STAT_INTERVAL). This is a bug.
2152+
* Note: we have a special case in pgstat code to ensure that the stats
2153+
* we read are as up-to-date as possible, to avoid the problem that
2154+
* somebody just finished vacuuming this table. The window to the race
2155+
* condition is not closed but it is very small.
21542156
*/
21552157
MemoryContextSwitchTo(AutovacMemCxt);
21562158
tab=table_recheck_autovac(relid,table_toast_map);

‎src/backend/postmaster/pgstat.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2008, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.182 2008/11/0301:17:08 tgl Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.183 2008/11/0319:03:41 alvherre Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -3381,16 +3381,23 @@ backend_read_statsfile(void)
33813381
/*
33823382
* We set the minimum acceptable timestamp to PGSTAT_STAT_INTERVAL msec
33833383
* before now. This indirectly ensures that the collector needn't write
3384-
* the file more often than PGSTAT_STAT_INTERVAL.
3384+
* the file more often than PGSTAT_STAT_INTERVAL. In an autovacuum
3385+
* worker, however, we want a lower delay to avoid using stale data, so we
3386+
* use PGSTAT_RETRY_DELAY (since the number of worker is low, this
3387+
* shouldn't be a problem).
33853388
*
33863389
* Note that we don't recompute min_ts after sleeping; so we might end up
33873390
* accepting a file a bit older than PGSTAT_STAT_INTERVAL. In practice
33883391
* that shouldn't happen, though, as long as the sleep time is less than
33893392
* PGSTAT_STAT_INTERVAL; and we don't want to lie to the collector about
33903393
* what our cutoff time really is.
33913394
*/
3392-
min_ts=TimestampTzPlusMilliseconds(GetCurrentTimestamp(),
3393-
-PGSTAT_STAT_INTERVAL);
3395+
if (IsAutoVacuumWorkerProcess())
3396+
min_ts=TimestampTzPlusMilliseconds(GetCurrentTimestamp(),
3397+
-PGSTAT_RETRY_DELAY);
3398+
else
3399+
min_ts=TimestampTzPlusMilliseconds(GetCurrentTimestamp(),
3400+
-PGSTAT_STAT_INTERVAL);
33943401

33953402
/*
33963403
* Loop until fresh enough stats file is available or we ran out of time.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp