slow-stat-simulate-v2.patch

text/plain

Filename: slow-stat-simulate-v2.patch
Type: text/plain
Part: 0
Message: Re: 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 v2
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 14afef6..4308df2 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3444,6 +3444,7 @@ pgstat_send_bgwriter(void)
 NON_EXEC_STATIC void
 PgstatCollectorMain(int argc, char *argv[])
 {
+	unsigned total = 0;
 	int			len;
 	PgStat_Msg	msg;
 	int			wr;
@@ -3555,6 +3556,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
 			 */
@@ -3947,6 +3952,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 a811265..064cf9f 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -63,6 +63,9 @@ begin
     SELECT (n_tup_ins > 0) INTO updated3
       FROM pg_stat_user_tables WHERE relname='trunc_stats_test';
 
+    raise log 'stats updated as of % snapshot: 1:% 2:% 3:%',
+      pg_stat_get_snapshot_timestamp(), updated1, updated2, updated3;
+
     exit when updated1 and updated2 and updated3;
 
     -- wait a little
diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql
index b3e2efa..d252124 100644
--- a/src/test/regress/sql/stats.sql
+++ b/src/test/regress/sql/stats.sql
@@ -58,6 +58,9 @@ begin
     SELECT (n_tup_ins > 0) INTO updated3
       FROM pg_stat_user_tables WHERE relname='trunc_stats_test';
 
+    raise log 'stats updated as of % snapshot: 1:% 2:% 3:%',
+      pg_stat_get_snapshot_timestamp(), updated1, updated2, updated3;
+
     exit when updated1 and updated2 and updated3;
 
     -- wait a little