Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 18808f8

Browse files
committed
Add wait events for recovery conflicts.
This commit introduces new wait events RecoveryConflictSnapshot and RecoveryConflictTablespace. The former is reported while waiting for recovery conflict resolution on a vacuum cleanup. The latter is reported while waiting for recovery conflict resolution on dropping tablespace. Also this commit changes the code so that the wait event Lock is reported while waiting in ResolveRecoveryConflictWithVirtualXIDs() for recovery conflict resolution on a lock. Basically the wait event Lock is reported during that wait, but previously was not reported only when that wait happened in ResolveRecoveryConflictWithVirtualXIDs(). Author: Masahiko Sawada Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/CA+fd4k4mXWTwfQLS3RPwGr4xnfAEs1ysFfgYHvmmoUgv6Zxvmg@mail.gmail.com
1 parent 9d8ef98 commit 18808f8

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

doc/src/sgml/monitoring.sgml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
13461346
<entry>Waiting in an extension.</entry>
13471347
</row>
13481348
<row>
1349-
<entry morerows="38"><literal>IPC</literal></entry>
1349+
<entry morerows="40"><literal>IPC</literal></entry>
13501350
<entry><literal>BackupWaitWalArchive</literal></entry>
13511351
<entry>Waiting for WAL files required for the backup to be successfully archived.</entry>
13521352
</row>
@@ -1482,6 +1482,14 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
14821482
<entry><literal>Promote</literal></entry>
14831483
<entry>Waiting for standby promotion.</entry>
14841484
</row>
1485+
<row>
1486+
<entry><literal>RecoveryConflictSnapshot</literal></entry>
1487+
<entry>Waiting for recovery conflict resolution on a vacuum cleanup.</entry>
1488+
</row>
1489+
<row>
1490+
<entry><literal>RecoveryConflictTablespace</literal></entry>
1491+
<entry>Waiting for recovery conflict resolution on dropping tablespace.</entry>
1492+
</row>
14851493
<row>
14861494
<entry><literal>RecoveryPause</literal></entry>
14871495
<entry>Waiting for recovery to be resumed.</entry>

src/backend/postmaster/pgstat.c

+6
Original file line numberDiff line numberDiff line change
@@ -3852,6 +3852,12 @@ pgstat_get_wait_ipc(WaitEventIPC w)
38523852
case WAIT_EVENT_PROMOTE:
38533853
event_name = "Promote";
38543854
break;
3855+
case WAIT_EVENT_RECOVERY_CONFLICT_SNAPSHOT:
3856+
event_name = "RecoveryConflictSnapshot";
3857+
break;
3858+
case WAIT_EVENT_RECOVERY_CONFLICT_TABLESPACE:
3859+
event_name = "RecoveryConflictTablespace";
3860+
break;
38553861
case WAIT_EVENT_RECOVERY_PAUSE:
38563862
event_name = "RecoveryPause";
38573863
break;

src/backend/storage/ipc/standby.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ int max_standby_streaming_delay = 30 * 1000;
4343
static HTAB *RecoveryLockLists;
4444

4545
static void ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
46-
ProcSignalReason reason, bool report_waiting);
46+
ProcSignalReason reason,
47+
uint32 wait_event_info,
48+
bool report_waiting);
4749
static void SendRecoveryConflictWithBufferPin(ProcSignalReason reason);
4850
static XLogRecPtr LogCurrentRunningXacts(RunningTransactions CurrRunningXacts);
4951
static void LogAccessExclusiveLocks(int nlocks, xl_standby_lock *locks);
@@ -184,7 +186,7 @@ static int standbyWait_us = STANDBY_INITIAL_WAIT_US;
184186
* more then we return true, if we can wait some more return false.
185187
*/
186188
static bool
187-
WaitExceedsMaxStandbyDelay(void)
189+
WaitExceedsMaxStandbyDelay(uint32 wait_event_info)
188190
{
189191
TimestampTz ltime;
190192

@@ -198,7 +200,9 @@ WaitExceedsMaxStandbyDelay(void)
198200
/*
199201
* Sleep a bit (this is essential to avoid busy-waiting).
200202
*/
203+
pgstat_report_wait_start(wait_event_info);
201204
pg_usleep(standbyWait_us);
205+
pgstat_report_wait_end();
202206

203207
/*
204208
* Progressively increase the sleep times, but not to more than 1s, since
@@ -223,7 +227,8 @@ WaitExceedsMaxStandbyDelay(void)
223227
*/
224228
static void
225229
ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
226-
ProcSignalReason reason, bool report_waiting)
230+
ProcSignalReason reason, uint32 wait_event_info,
231+
bool report_waiting)
227232
{
228233
TimestampTz waitStart = 0;
229234
char *new_status;
@@ -264,7 +269,7 @@ ResolveRecoveryConflictWithVirtualXIDs(VirtualTransactionId *waitlist,
264269
}
265270

266271
/* Is it time to kill it? */
267-
if (WaitExceedsMaxStandbyDelay())
272+
if (WaitExceedsMaxStandbyDelay(wait_event_info))
268273
{
269274
pid_t pid;
270275

@@ -317,6 +322,7 @@ ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid, RelFileNode
317322

318323
ResolveRecoveryConflictWithVirtualXIDs(backends,
319324
PROCSIG_RECOVERY_CONFLICT_SNAPSHOT,
325+
WAIT_EVENT_RECOVERY_CONFLICT_SNAPSHOT,
320326
true);
321327
}
322328

@@ -346,6 +352,7 @@ ResolveRecoveryConflictWithTablespace(Oid tsid)
346352
InvalidOid);
347353
ResolveRecoveryConflictWithVirtualXIDs(temp_file_users,
348354
PROCSIG_RECOVERY_CONFLICT_TABLESPACE,
355+
WAIT_EVENT_RECOVERY_CONFLICT_TABLESPACE,
349356
true);
350357
}
351358

@@ -417,6 +424,7 @@ ResolveRecoveryConflictWithLock(LOCKTAG locktag)
417424
*/
418425
ResolveRecoveryConflictWithVirtualXIDs(backends,
419426
PROCSIG_RECOVERY_CONFLICT_LOCK,
427+
PG_WAIT_LOCK | locktag.locktag_type,
420428
false);
421429
}
422430
else

src/include/pgstat.h

+2
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,8 @@ typedef enum
881881
WAIT_EVENT_PARALLEL_FINISH,
882882
WAIT_EVENT_PROCARRAY_GROUP_UPDATE,
883883
WAIT_EVENT_PROMOTE,
884+
WAIT_EVENT_RECOVERY_CONFLICT_SNAPSHOT,
885+
WAIT_EVENT_RECOVERY_CONFLICT_TABLESPACE,
884886
WAIT_EVENT_RECOVERY_PAUSE,
885887
WAIT_EVENT_REPLICATION_ORIGIN_DROP,
886888
WAIT_EVENT_REPLICATION_SLOT_DROP,

0 commit comments

Comments
 (0)