stat-coalesce-v1.patch

text/plain

Filename: stat-coalesce-v1.patch
Type: text/plain
Part: 0
Message: Re: PATCH: Split stats file per database WAS: autovacuum stress-testing our system

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
Series: patch v1
File+
src/backend/postmaster/pgstat.c 12 0
src/test/regress/expected/stats.out 3 0
src/test/regress/sql/stats.sql 3 0
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index ab018c4..e6f04b0 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3314,6 +3314,7 @@ pgstat_send_bgwriter(void)
 NON_EXEC_STATIC void
 PgstatCollectorMain(int argc, char *argv[])
 {
+	unsigned total = 0;
 	int			len;
 	PgStat_Msg	msg;
 	int			wr;
@@ -3425,6 +3426,10 @@ PgstatCollectorMain(int argc, char *argv[])
 						 errmsg("could not read statistics message: %m")));
 			}
 
+			elog(LOG, "stats %d: %u + %u = %u",
+				 msg.msg_hdr.m_type, total, len, total + len);
+			total += len;
+
 			/*
 			 * We ignore messages that are smaller than our common header
 			 */
@@ -3817,6 +3822,13 @@ pgstat_write_statsfiles(bool permanent, bool allDbs)
 	 */
 	fputc('E', fpout);
 
+	if (1)
+	{
+		PG_SETMASK(&BlockSig);
+		pg_usleep(3 * 1000000L);
+		PG_SETMASK(&UnBlockSig);
+	}
+
 	if (ferror(fpout))
 	{
 		ereport(LOG,
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out
index f5be70f..b042062 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -47,6 +47,9 @@ begin
       FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
      WHERE st.relname='tenk2' AND cl.relname='tenk2';
 
+    raise log 'stats updated as of % snapshot: %',
+      pg_stat_get_snapshot_timestamp(), updated;
+
     exit when updated;
 
     -- wait a little
diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql
index cd2d592..e87454d 100644
--- a/src/test/regress/sql/stats.sql
+++ b/src/test/regress/sql/stats.sql
@@ -42,6 +42,9 @@ begin
       FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
      WHERE st.relname='tenk2' AND cl.relname='tenk2';
 
+    raise log 'stats updated as of % snapshot: %',
+      pg_stat_get_snapshot_timestamp(), updated;
+
     exit when updated;
 
     -- wait a little