Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc534fc

Browse files
committed
Report missing wait event for timeline history file.
TimelineHistoryRead and TimelineHistoryWrite wait events are reportedduring waiting for a read and write of a timeline history file, respectively.However, previously, TimelineHistoryRead wait event was not reportedwhile readTimeLineHistory() was reading a timeline history file. AlsoTimelineHistoryWrite was not reported while writeTimeLineHistory() waswriting one line with the details of the timeline split, at the end.This commit fixes these issues.Back-patch to v10 where wait events for a timeline history file was added.Author: Masahiro IkedaReviewed-by: Michael Paquier, Fujii MasaoDiscussion:https://postgr.es/m/d11b0c910b63684424e06772eb844ab5@oss.nttdata.com
1 parent5db4880 commitcc534fc

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

‎src/backend/access/transam/timeline.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ readTimeLineHistory(TimeLineID targetTLI)
7777
List*result;
7878
charpath[MAXPGPATH];
7979
charhistfname[MAXFNAMELEN];
80-
charfline[MAXPGPATH];
8180
FILE*fd;
8281
TimeLineHistoryEntry*entry;
8382
TimeLineIDlasttli=0;
@@ -122,15 +121,30 @@ readTimeLineHistory(TimeLineID targetTLI)
122121
* Parse the file...
123122
*/
124123
prevend=InvalidXLogRecPtr;
125-
while (fgets(fline,sizeof(fline),fd)!=NULL)
124+
for (;;)
126125
{
127-
/* skip leading whitespace and check for # comment */
126+
charfline[MAXPGPATH];
127+
char*res;
128128
char*ptr;
129129
TimeLineIDtli;
130130
uint32switchpoint_hi;
131131
uint32switchpoint_lo;
132132
intnfields;
133133

134+
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_READ);
135+
res=fgets(fline,sizeof(fline),fd);
136+
pgstat_report_wait_end();
137+
if (res==NULL)
138+
{
139+
if (ferror(fd))
140+
ereport(ERROR,
141+
(errcode_for_file_access(),
142+
errmsg("could not read file \"%s\": %m",path)));
143+
144+
break;
145+
}
146+
147+
/* skip leading whitespace and check for # comment */
134148
for (ptr=fline;*ptr;ptr++)
135149
{
136150
if (!isspace((unsignedchar)*ptr))
@@ -388,6 +402,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
388402

389403
nbytes=strlen(buffer);
390404
errno=0;
405+
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_WRITE);
391406
if ((int)write(fd,buffer,nbytes)!=nbytes)
392407
{
393408
intsave_errno=errno;
@@ -403,6 +418,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
403418
(errcode_for_file_access(),
404419
errmsg("could not write to file \"%s\": %m",tmppath)));
405420
}
421+
pgstat_report_wait_end();
406422

407423
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_SYNC);
408424
if (pg_fsync(fd)!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp