wait_event_wal_fsync.patch
text/x-patch
Filename: wait_event_wal_fsync.patch
Type: text/x-patch
Part: 0
Message:
Monitoring time of fsyncing WALs
Patch
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/monitoring.sgml | 4 | 0 |
| src/backend/access/transam/xlog.c | 2 | 0 |
| src/backend/postmaster/pgstat.c | 3 | 0 |
| src/include/pgstat.h | 2 | 1 |
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index c2adb22..ef0addd 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -1682,6 +1682,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry><literal>WALWrite</literal></entry>
<entry>Waiting for a write to a WAL file.</entry>
</row>
+ <row>
+ <entry><literal>WALFsync</literal></entry>
+ <entry>Waiting for a fsync for WAL segment.</entry>
+ </row>
</tbody>
</tgroup>
</table>
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 1a419aa..0956655 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -10156,6 +10156,7 @@ assign_xlog_sync_method(int new_sync_method, void *extra)
void
issue_xlog_fsync(int fd, XLogSegNo segno)
{
+ pgstat_report_wait_start(WAIT_EVENT_WAL_FSYNC);
switch (sync_method)
{
case SYNC_METHOD_FSYNC:
@@ -10191,6 +10192,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno)
elog(PANIC, "unrecognized wal_sync_method: %d", sync_method);
break;
}
+ pgstat_report_wait_end();
}
/*
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 084573e..adbf6af 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -3931,6 +3931,9 @@ pgstat_get_wait_io(WaitEventIO w)
case WAIT_EVENT_WAL_WRITE:
event_name = "WALWrite";
break;
+ case WAIT_EVENT_WAL_FSYNC:
+ event_name = "WALFsync";
+ break;
/* no default case, so that compiler will warn */
}
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index be2f592..b76074b 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -922,7 +922,8 @@ typedef enum
WAIT_EVENT_WAL_INIT_WRITE,
WAIT_EVENT_WAL_READ,
WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN,
- WAIT_EVENT_WAL_WRITE
+ WAIT_EVENT_WAL_WRITE,
+ WAIT_EVENT_WAL_FSYNC
} WaitEventIO;
/* ----------