Break-initdb-with-pending-stats.patch
text/x-patch
Filename: Break-initdb-with-pending-stats.patch
Type: text/x-patch
Part: 0
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: format-patch
Subject: Break initdb with pending stats
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 2 | 0 |
| src/backend/access/transam/xlogrecovery.c | 5 | 0 |
From 93bbfd611b86654356a84415367fe562eae74b68 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Thu, 16 Jan 2025 10:10:46 +0300
Subject: [PATCH] Break initdb with pending stats
To reproduce, run initdb on asserts enabled build.
---
src/backend/access/transam/xlog.c | 2 ++
src/backend/access/transam/xlogrecovery.c | 5 +++++
2 files changed, 7 insertions(+)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index bf3dbda901d..857f8379f3e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3322,6 +3322,8 @@ XLogFileInitInternal(XLogSegNo logsegno, TimeLineID logtli,
}
pgstat_report_wait_end();
+ pgstat_count_io_op(IOOBJECT_RELATION, IOCONTEXT_NORMAL, IOOP_FSYNC, 1, 0);
+
if (close(fd) != 0)
ereport(ERROR,
(errcode_for_file_access(),
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 0bbe2eea206..cc29b19ca0a 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -3406,6 +3406,9 @@ retry:
int save_errno = errno;
pgstat_report_wait_end();
+
+ pgstat_count_io_op(IOOBJECT_RELATION, IOCONTEXT_NORMAL, IOOP_READ, 1, r);
+
XLogFileName(fname, curFileTLI, readSegNo, wal_segment_size);
if (r < 0)
{
@@ -3426,6 +3429,8 @@ retry:
}
pgstat_report_wait_end();
+ pgstat_count_io_op(IOOBJECT_RELATION, IOCONTEXT_NORMAL, IOOP_READ, 1, r);
+
Assert(targetSegNo == readSegNo);
Assert(targetPageOff == readOff);
Assert(reqLen <= readLen);
--
2.47.1