58
58
#include "storage/reinit.h"
59
59
#include "storage/smgr.h"
60
60
#include "storage/spin.h"
61
+ #include "storage/wait.h"
61
62
#include "utils/builtins.h"
62
63
#include "utils/guc.h"
63
64
#include "utils/ps_status.h"
@@ -2446,6 +2447,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
2446
2447
from = XLogCtl -> pages + startidx * (Size ) XLOG_BLCKSZ ;
2447
2448
nbytes = npages * (Size ) XLOG_BLCKSZ ;
2448
2449
nleft = nbytes ;
2450
+
2451
+ WAIT_START (WAIT_IO , WAIT_XLOG_WRITE , 0 , 0 , 0 , 0 , 0 );
2449
2452
do
2450
2453
{
2451
2454
errno = 0 ;
@@ -2465,6 +2468,8 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
2465
2468
from += written ;
2466
2469
} while (nleft > 0 );
2467
2470
2471
+ WAIT_STOP ();
2472
+
2468
2473
/* Update state for write */
2469
2474
openLogOff += nbytes ;
2470
2475
npages = 0 ;
@@ -3177,6 +3182,8 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
3177
3182
*/
3178
3183
zbuffer = (char * ) MAXALIGN (zbuffer_raw );
3179
3184
memset (zbuffer , 0 , XLOG_BLCKSZ );
3185
+
3186
+ WAIT_START (WAIT_IO , WAIT_XLOG_WRITE , 0 , 0 , 0 , 0 , 0 );
3180
3187
for (nbytes = 0 ; nbytes < XLogSegSize ; nbytes += XLOG_BLCKSZ )
3181
3188
{
3182
3189
errno = 0 ;
@@ -3199,7 +3206,9 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
3199
3206
errmsg ("could not write to file \"%s\": %m" , tmppath )));
3200
3207
}
3201
3208
}
3209
+ WAIT_STOP ();
3202
3210
3211
+ WAIT_START (WAIT_IO , WAIT_XLOG_FSYNC , 0 , 0 , 0 , 0 , 0 );
3203
3212
if (pg_fsync (fd ) != 0 )
3204
3213
{
3205
3214
close (fd );
@@ -3208,6 +3217,8 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
3208
3217
errmsg ("could not fsync file \"%s\": %m" , tmppath )));
3209
3218
}
3210
3219
3220
+ WAIT_STOP ();
3221
+
3211
3222
if (close (fd ))
3212
3223
ereport (ERROR ,
3213
3224
(errcode_for_file_access (),
@@ -4877,11 +4888,12 @@ XLOGShmemInit(void)
4877
4888
4878
4889
XLogCtl -> Insert .WALInsertLockTrancheId = LWLockNewTrancheId ();
4879
4890
4880
- XLogCtl -> Insert .WALInsertLockTranche .name = "WALInsertLocks" ;
4891
+ strcpy ( XLogCtl -> Insert .WALInsertLockTranche .name , "WALInsertLocks" ) ;
4881
4892
XLogCtl -> Insert .WALInsertLockTranche .array_base = WALInsertLocks ;
4882
4893
XLogCtl -> Insert .WALInsertLockTranche .array_stride = sizeof (WALInsertLockPadded );
4883
4894
4884
- LWLockRegisterTranche (XLogCtl -> Insert .WALInsertLockTrancheId , & XLogCtl -> Insert .WALInsertLockTranche );
4895
+ LWLockRegisterTranche (XLogCtl -> Insert .WALInsertLockTrancheId ,
4896
+ & XLogCtl -> Insert .WALInsertLockTranche );
4885
4897
for (i = 0 ; i < NUM_XLOGINSERT_LOCKS ; i ++ )
4886
4898
{
4887
4899
LWLockInitialize (& WALInsertLocks [i ].l .lock ,
@@ -9718,6 +9730,7 @@ assign_xlog_sync_method(int new_sync_method, void *extra)
9718
9730
void
9719
9731
issue_xlog_fsync (int fd , XLogSegNo segno )
9720
9732
{
9733
+ WAIT_START (WAIT_IO , WAIT_XLOG_FSYNC , 0 , 0 , 0 , 0 , 0 );
9721
9734
switch (sync_method )
9722
9735
{
9723
9736
case SYNC_METHOD_FSYNC :
@@ -9753,6 +9766,7 @@ issue_xlog_fsync(int fd, XLogSegNo segno)
9753
9766
elog (PANIC , "unrecognized wal_sync_method: %d" , sync_method );
9754
9767
break ;
9755
9768
}
9769
+ WAIT_STOP ();
9756
9770
}
9757
9771
9758
9772
/*
@@ -10838,8 +10852,10 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
10838
10852
goto next_record_is_invalid ;
10839
10853
}
10840
10854
10855
+ WAIT_START (WAIT_IO , WAIT_XLOG_READ , 0 , 0 , 0 , 0 , 0 );
10841
10856
if (read (readFile , readBuf , XLOG_BLCKSZ ) != XLOG_BLCKSZ )
10842
10857
{
10858
+ WAIT_STOP ();
10843
10859
char fname [MAXFNAMELEN ];
10844
10860
10845
10861
XLogFileName (fname , curFileTLI , readSegNo );
@@ -10849,6 +10865,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
10849
10865
fname , readOff )));
10850
10866
goto next_record_is_invalid ;
10851
10867
}
10868
+ WAIT_STOP ();
10852
10869
10853
10870
Assert (targetSegNo == readSegNo );
10854
10871
Assert (targetPageOff == readOff );
0 commit comments