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

Commitf2ff203

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 parentcd8c73a commitf2ff203

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
@@ -78,7 +78,6 @@ readTimeLineHistory(TimeLineID targetTLI)
7878
List*result;
7979
charpath[MAXPGPATH];
8080
charhistfname[MAXFNAMELEN];
81-
charfline[MAXPGPATH];
8281
FILE*fd;
8382
TimeLineHistoryEntry*entry;
8483
TimeLineIDlasttli=0;
@@ -123,15 +122,30 @@ readTimeLineHistory(TimeLineID targetTLI)
123122
* Parse the file...
124123
*/
125124
prevend=InvalidXLogRecPtr;
126-
while (fgets(fline,sizeof(fline),fd)!=NULL)
125+
for (;;)
127126
{
128-
/* skip leading whitespace and check for # comment */
127+
charfline[MAXPGPATH];
128+
char*res;
129129
char*ptr;
130130
TimeLineIDtli;
131131
uint32switchpoint_hi;
132132
uint32switchpoint_lo;
133133
intnfields;
134134

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

394408
nbytes=strlen(buffer);
395409
errno=0;
410+
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_WRITE);
396411
if ((int)write(fd,buffer,nbytes)!=nbytes)
397412
{
398413
intsave_errno=errno;
@@ -408,6 +423,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
408423
(errcode_for_file_access(),
409424
errmsg("could not write to file \"%s\": %m",tmppath)));
410425
}
426+
pgstat_report_wait_end();
411427

412428
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_SYNC);
413429
if (pg_fsync(fd)!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp