v2-0001-Fix-inconsistency-in-determining-the-timestamp-of.patch

application/octet-stream

Filename: v2-0001-Fix-inconsistency-in-determining-the-timestamp-of.patch
Type: application/octet-stream
Part: 0
Message: Re: Inconsistency in determining the timestamp of the db statfile.

Patch

Format: format-patch
Series: patch v2-0001
Subject: Fix inconsistency in determining the timestamp of the db statfile.
File+
src/backend/postmaster/pgstat.c 4 2
From dc0e7fd8d3e3920f5ecdbd8d4f02cbb92e856361 Mon Sep 17 00:00:00 2001
From: Amit Kapila <akapila@postgresql.org>
Date: Thu, 10 Sep 2020 09:58:20 +0530
Subject: [PATCH v2] Fix inconsistency in determining the timestamp of the db
 statfile.

We use the timestamp of the global statfile if we are not able to
determine it for a particular database in case the entry for that database
doesn't exist. However, we were using it even when the statfile is
corrupt.

Discussion: https://postgr.es/m/CAA4eK1J3oTJKyVq6v7K4d3jD+vtnruG9fHRib6UuWWsrwAR6Aw@mail.gmail.com
---
 src/backend/postmaster/pgstat.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 5f4b168fd1..019e7e2ede 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -5557,7 +5557,8 @@ done:
  * pgstat_read_db_statsfile_timestamp() -
  *
  *	Attempt to determine the timestamp of the last db statfile write.
- *	Returns true if successful; the timestamp is stored in *ts.
+ *	Returns true if successful; the timestamp is stored in *ts. The caller must
+ *	rely on timestamp stored in *ts iff the function returns true.
  *
  *	This needs to be careful about handling databases for which no stats file
  *	exists, such as databases without a stat entry or those not yet written:
@@ -5665,7 +5666,8 @@ pgstat_read_db_statsfile_timestamp(Oid databaseid, bool permanent,
 					ereport(pgStatRunningInCollector ? LOG : WARNING,
 							(errmsg("corrupted statistics file \"%s\"",
 									statfile)));
-					goto done;
+					FreeFile(fpin);
+					return false;
 				}
 
 				/*
-- 
2.28.0.windows.1