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

Commit52e8fc3

Browse files
committed
Ensure that backends see up-to-date statistics for shared catalogs.
Ever since we split the statistics collector's reports into per-databasefiles (commit187492b), backends have been seeing stale statisticsfor shared catalogs. This is because the inquiry message only prompts thecollector to write the per-database file for the requesting backend's owndatabase. Stats for shared catalogs are in a separate file for "DB 0",which didn't get updated.In normal operation this was partially masked by the fact that theautovacuum launcher would send an inquiry message at least once perautovacuum_naptime that asked for "DB 0"; so the shared-catalog stats wouldnever be more than a minute out of date. However the problem becomes veryobvious with autovacuum disabled, as reported by Peter Eisentraut.To fix, redefine the semantics of inquiry messages so that both thespecified DB and DB 0 will be dumped. (This might seem a bit inefficient,but we have no good way to know whether a backend's transaction will lookat shared-catalog stats, so we have to read both groups of stats wheneverwe request stats. Sending two inquiry messages would definitely not bebetter.)Back-patch to 9.3 where the bug was introduced.Report: <56AD41AC.1030509@gmx.net>
1 parent9abd64e commit52e8fc3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5504,7 +5504,16 @@ pgstat_db_requested(Oid databaseid)
55045504
{
55055505
slist_iteriter;
55065506

5507-
/* Check the databases if they need to refresh the stats. */
5507+
/*
5508+
* If any requests are outstanding at all, we should write the stats for
5509+
* shared catalogs (the "database" with OID 0). This ensures that
5510+
* backends will see up-to-date stats for shared catalogs, even though
5511+
* they send inquiry messages mentioning only their own DB.
5512+
*/
5513+
if (databaseid==InvalidOid&& !slist_is_empty(&last_statrequests))
5514+
return true;
5515+
5516+
/* Search to see if there's an open request to write this database. */
55085517
slist_foreach(iter,&last_statrequests)
55095518
{
55105519
DBWriteRequest*req=slist_container(DBWriteRequest,next,iter.cur);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp