mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Remove incomplete pgstats entry for allocation failure at startup
pgstat_init_entry() can fail after its hash entry has been inserted, in which case the caller has to remove the entry, as done by pgstat_get_entry_ref() since8191e0c16a. pgstat_read_statsfile() was not exactly doing that, leaving an entry that could still point to an InvalidDsaPointer. There are no consequences here, even after8191e0c16a. The stats are loaded from disk by the startup process, where an ERROR gets promoted to a FATAL, cleaning up shared memory. So this is mostly an argument of consistency with the normal entry creation path, especially if someone decides to downgrade this ERROR to a WARNING in pgstat_read_statsfile(). Author: Grigorev Jurij <ju.grigorev@ftdata.ru> Discussion: https://postgr.es/m/d55ecaf911844d53bd0a931751dce582@localhost.localdomain
This commit is contained in:
@@ -2109,9 +2109,10 @@ pgstat_read_statsfile(void)
|
||||
}
|
||||
|
||||
header = pgstat_init_entry(key.kind, p);
|
||||
dshash_release_lock(pgStatLocal.shared_hash, p);
|
||||
if (header == NULL)
|
||||
{
|
||||
dshash_delete_entry(pgStatLocal.shared_hash, p);
|
||||
|
||||
/*
|
||||
* It would be tempting to switch this ERROR to a
|
||||
* WARNING, but it would mean that all the statistics
|
||||
@@ -2121,6 +2122,7 @@ pgstat_read_statsfile(void)
|
||||
key.kind, key.dboid,
|
||||
key.objid, t);
|
||||
}
|
||||
dshash_release_lock(pgStatLocal.shared_hash, p);
|
||||
|
||||
if (!read_chunk(fpin,
|
||||
pgstat_get_entry_data(key.kind, header),
|
||||
|
||||
Reference in New Issue
Block a user