mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-06 02:39:21 +02:00
Report missing wait event for timeline history file.
TimelineHistoryRead and TimelineHistoryWrite wait events are reported during waiting for a read and write of a timeline history file, respectively. However, previously, TimelineHistoryRead wait event was not reported while readTimeLineHistory() was reading a timeline history file. Also TimelineHistoryWrite was not reported while writeTimeLineHistory() was writing 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 Ikeda Reviewed-by: Michael Paquier, Fujii Masao Discussion: https://postgr.es/m/d11b0c910b63684424e06772eb844ab5@oss.nttdata.com
This commit is contained in:
parent
e1d70ba438
commit
a354d01538
@ -77,7 +77,6 @@ readTimeLineHistory(TimeLineID targetTLI)
|
|||||||
List *result;
|
List *result;
|
||||||
char path[MAXPGPATH];
|
char path[MAXPGPATH];
|
||||||
char histfname[MAXFNAMELEN];
|
char histfname[MAXFNAMELEN];
|
||||||
char fline[MAXPGPATH];
|
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
TimeLineHistoryEntry *entry;
|
TimeLineHistoryEntry *entry;
|
||||||
TimeLineID lasttli = 0;
|
TimeLineID lasttli = 0;
|
||||||
@ -122,15 +121,30 @@ readTimeLineHistory(TimeLineID targetTLI)
|
|||||||
* Parse the file...
|
* Parse the file...
|
||||||
*/
|
*/
|
||||||
prevend = InvalidXLogRecPtr;
|
prevend = InvalidXLogRecPtr;
|
||||||
while (fgets(fline, sizeof(fline), fd) != NULL)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* skip leading whitespace and check for # comment */
|
char fline[MAXPGPATH];
|
||||||
|
char *res;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
TimeLineID tli;
|
TimeLineID tli;
|
||||||
uint32 switchpoint_hi;
|
uint32 switchpoint_hi;
|
||||||
uint32 switchpoint_lo;
|
uint32 switchpoint_lo;
|
||||||
int nfields;
|
int nfields;
|
||||||
|
|
||||||
|
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_READ);
|
||||||
|
res = fgets(fline, sizeof(fline), fd);
|
||||||
|
pgstat_report_wait_end();
|
||||||
|
if (res == NULL)
|
||||||
|
{
|
||||||
|
if (ferror(fd))
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode_for_file_access(),
|
||||||
|
errmsg("could not read file \"%s\": %m", path)));
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* skip leading whitespace and check for # comment */
|
||||||
for (ptr = fline; *ptr; ptr++)
|
for (ptr = fline; *ptr; ptr++)
|
||||||
{
|
{
|
||||||
if (!isspace((unsigned char) *ptr))
|
if (!isspace((unsigned char) *ptr))
|
||||||
@ -392,6 +406,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
|
|||||||
|
|
||||||
nbytes = strlen(buffer);
|
nbytes = strlen(buffer);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_WRITE);
|
||||||
if ((int) write(fd, buffer, nbytes) != nbytes)
|
if ((int) write(fd, buffer, nbytes) != nbytes)
|
||||||
{
|
{
|
||||||
int save_errno = errno;
|
int save_errno = errno;
|
||||||
@ -407,6 +422,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
|
|||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("could not write to file \"%s\": %m", tmppath)));
|
errmsg("could not write to file \"%s\": %m", tmppath)));
|
||||||
}
|
}
|
||||||
|
pgstat_report_wait_end();
|
||||||
|
|
||||||
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_SYNC);
|
pgstat_report_wait_start(WAIT_EVENT_TIMELINE_HISTORY_SYNC);
|
||||||
if (pg_fsync(fd) != 0)
|
if (pg_fsync(fd) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user