Add wait event for fsync of WAL segments
authorMichael Paquier <michael@paquier.xyz>
Mon, 2 Jul 2018 13:19:46 +0000 (22:19 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 2 Jul 2018 13:19:46 +0000 (22:19 +0900)
This has been visibly a forgotten spot in the first implementation of
wait events for I/O added by 249cf07, and what has been missing is a
fsync call for WAL segments which is a wrapper reacting on the value of
GUC wal_sync_method.

Reported-by: Konstantin Knizhnik
Author: Konstantin Knizhnik
Reviewed-by: Craig Ringer, Michael Paquier
Discussion: https://postgr.es/m/4a243897-0ad8-f471-aa40-242591f2476e@postgrespro.ru

doc/src/sgml/monitoring.sgml
src/backend/access/transam/xlog.c
src/backend/postmaster/pgstat.c
src/include/pgstat.h

index c2adb22dff988364c0233ec2cf3c73a0ddc04862..36d393d329cdce631ece46871ea7be404cf2c3b1 100644 (file)
@@ -1674,6 +1674,10 @@ postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: ser
          <entry><literal>WALSenderTimelineHistoryRead</literal></entry>
          <entry>Waiting for a read from a timeline history file during walsender timeline command.</entry>
         </row>
+        <row>
+         <entry><literal>WALSync</literal></entry>
+         <entry>Waiting for a WAL file to reach stable storage.</entry>
+        </row>
         <row>
          <entry><literal>WALSyncMethodAssign</literal></entry>
          <entry>Waiting for data to reach stable storage while assigning WAL sync method.</entry>
index dcfef365916a4c85f7f41e18d2ee5f35351fc080..098165780128759223160cb84e44304700e94882 100644 (file)
@@ -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_SYNC);
        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();
 }
 
 /*
index 084573e77c0d29c9fd5eeb2b0f1c2457805615f8..bbe73618c786c1c884c08c5f133234c721c644bd 100644 (file)
@@ -3925,6 +3925,9 @@ pgstat_get_wait_io(WaitEventIO w)
                case WAIT_EVENT_WAL_READ:
                        event_name = "WALRead";
                        break;
+               case WAIT_EVENT_WAL_SYNC:
+                       event_name = "WALSync";
+                       break;
                case WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN:
                        event_name = "WALSyncMethodAssign";
                        break;
index be2f59239bf9d7e7512cffedb6ab8e0f838da103..d59c24ae2381a4d10ade4d54a55066fc62d88511 100644 (file)
@@ -921,6 +921,7 @@ typedef enum
        WAIT_EVENT_WAL_INIT_SYNC,
        WAIT_EVENT_WAL_INIT_WRITE,
        WAIT_EVENT_WAL_READ,
+       WAIT_EVENT_WAL_SYNC,
        WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN,
        WAIT_EVENT_WAL_WRITE
 } WaitEventIO;