1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

pgstat: Use correct lock level in pgstat_drop_all_entries().

Previously we didn't, which lead to an assertion failure when resetting
partially loaded statistics. This was encountered on the buildfarm, for
as-of-yet unknown reasons.

Ttighten up a validity check when reading the stats file, verifying 'E'
signals the end of the file (rather than just stopping reading). That's then
used in a test appending to the stats file that crashed before the fix in
pgstat_drop_all_entries().

Reported by buildfarm animals mylodon and kestrel, via Tom Lane.

Discussion: https://postgr.es/m/1656446.1650043715@sss.pgh.pa.us
This commit is contained in:
Andres Freund
2022-04-16 12:13:31 -07:00
parent 9f4f0a0dad
commit 4a736a161c
3 changed files with 33 additions and 3 deletions

View File

@@ -1583,6 +1583,10 @@ pgstat_read_statsfile(void)
break;
}
case 'E':
/* check that 'E' actually signals end of file */
if (fgetc(fpin) != EOF)
goto error;
goto done;
default:

View File

@@ -878,7 +878,7 @@ pgstat_drop_all_entries(void)
PgStatShared_HashEntry *ps;
uint64 not_freed_count = 0;
dshash_seq_init(&hstat, pgStatLocal.shared_hash, false);
dshash_seq_init(&hstat, pgStatLocal.shared_hash, true);
while ((ps = dshash_seq_next(&hstat)) != NULL)
{
if (ps->dropped)