written = pg_pwrite(openLogFile, from, nleft, startoffset);
pgstat_report_wait_end();
- pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL,
- IOOP_WRITE, start, 1, written);
-
if (written <= 0)
{
char xlogfname[MAXFNAMELEN];
errmsg("could not write to log file \"%s\" at offset %u, length %zu: %m",
xlogfname, startoffset, nleft)));
}
+
+ pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL,
+ IOOP_WRITE, start, 1, written);
nleft -= written;
from += written;
startoffset += written;
}
pgstat_report_wait_end();
- /*
- * A full segment worth of data is written when using wal_init_zero. One
- * byte is written when not using it.
- */
- pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_INIT, IOOP_WRITE,
- io_start, 1,
- wal_init_zero ? wal_segment_size : 1);
-
if (save_errno)
{
/*
errmsg("could not write to file \"%s\": %m", tmppath)));
}
+ /*
+ * A full segment worth of data is written when using wal_init_zero. One
+ * byte is written when not using it.
+ */
+ pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_INIT, IOOP_WRITE,
+ io_start, 1,
+ wal_init_zero ? wal_segment_size : 1);
+
/* Measure I/O timing when flushing segment */
io_start = pgstat_prepare_io_time(track_wal_io_timing);
#ifndef FRONTEND
pgstat_report_wait_end();
-
- pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_READ,
- io_start, 1, readbytes);
#endif
if (readbytes <= 0)
return false;
}
+#ifndef FRONTEND
+ pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_READ,
+ io_start, 1, readbytes);
+#endif
+
/* Update state for read */
recptr += readbytes;
nbytes -= readbytes;
pgstat_report_wait_end();
- pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_READ,
- io_start, 1, r);
+ /* Count I/O stats only for successful short reads */
+ if (r > 0)
+ pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL, IOOP_READ,
+ io_start, 1, r);
XLogFileName(fname, curFileTLI, readSegNo, wal_segment_size);
if (r < 0)
byteswritten = pg_pwrite(recvFile, buf, segbytes, (pgoff_t) startoff);
pgstat_report_wait_end();
- pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL,
- IOOP_WRITE, start, 1, byteswritten);
-
if (byteswritten <= 0)
{
char xlogfname[MAXFNAMELEN];
xlogfname, startoff, segbytes)));
}
+ pgstat_count_io_op_time(IOOBJECT_WAL, IOCONTEXT_NORMAL,
+ IOOP_WRITE, start, 1, byteswritten);
+
/* Update state for write */
recptr += byteswritten;