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
From 2e6f342024a075903910b94b37292efd3aa1f3a8 Mon Sep 17 00:00:00 2001
From: Masahiro Ikeda <ikeda...@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.c
index 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 via email to