From: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
To: pgsql-hackers@postgresql.org
Subject: Why are wait events not reported even though it reads/writes a timeline history file?
Date: Fri, 24 Apr 2020 11:29:43 +0900
Message-ID: <d11b0c910b63684424e06772eb844ab5@oss.nttdata.com> (raw)
Hi,
There are two unexpected codes for me about wait events for timeline
history file.
Please let me know your thoughts whether if we need to change.
1. readTimeLineHistory() function in timeline.c
The readTimeLineHistory() reads a timeline history file,
but it doesn't report “WAIT_EVENT_TIMELINE_HISTORY_READ".
In my understanding, sscanf() is blocking read.
So, it's important to report a wait event.
2. writeTimeLineHistory() function in timeline.c
The writeTimeLineHistory() function may write a timeline history file
twice,
but it reports “WAIT_EVENT_TIMELINE_HISTORY_WRITE" only once.
It makes sense to report a wait event twice, because both of them use
write().
I attached a patch to mention the code line number.
I checked the commit log which "WAIT_EVENT_TIMELINE_HISTORY_READ" and
"WAIT_EVENT_TIMELINE_HISTORY_WRITE" are committed and the discussion
about it.
But I can't find the reason.
Please give me your comments.
If we need to change, I can make a patch to fix them.
By the way, which is correct "timeline's history file" or "timeline
history file"?
The timeline.c has both. In my understanding, the latter is correct. If
so, I will modify together.
Regards,
--
Masahiro Ikeda
NTT DATA CORPORATION
Attachments:
[text/x-diff] 0001-some-wait-events-for-timeline-history-file-are-not-r.patch (1.2K, ../d11b0c910b63684424e06772eb844ab5@oss.nttdata.com/2-0001-some-wait-events-for-timeline-history-file-are-not-r.patch)
download | inline diff:
From 2e6f342024a075903910b94b37292efd3aa1f3a8 Mon Sep 17 00:00:00 2001
From: Masahiro Ikeda <ikedamsh@oss.nttdata.com>
Date: Thu, 23 Apr 2020 16:24:07 +0900
Subject: [PATCH] some wait events for timeline history file are not reported.
---
src/backend/access/transam/timeline.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.cindex de57d699af..f140100505 100644--- a/src/backend/access/transam/timeline.c+++ b/src/backend/access/transam/timeline.c@@ -140,6 +140,8 @@ readTimeLineHistory(TimeLineID targetTLI)
if (*ptr == '\0' || *ptr == '#')
continue;
+ # Try to read a timeline history file.+ # But, it doesn't report "WAIT_EVENT_TIMELINE_HISTORY_READ".
nfields = sscanf(fline, "%u\t%X/%X", &tli, &switchpoint_hi, &switchpoint_lo);
if (nfields < 1)
@@ -393,6 +395,8 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
nbytes = strlen(buffer);
errno = 0;
+ # Try to write a timeline history file.+ # But, it doesn't report "WAIT_EVENT_TIMELINE_HISTORY_WRITE".
if ((int) write(fd, buffer, nbytes) != nbytes)
{
int save_errno = errno;
--
2.24.2 (Apple Git-127)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: ikedamsh@oss.nttdata.com
Subject: Re: Why are wait events not reported even though it reads/writes a timeline history file?
In-Reply-To: <d11b0c910b63684424e06772eb844ab5@oss.nttdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox