mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Create and use wait events for read, write, and fsync operations.
Previous commits, notably53be0b1add
and6f3bd98ebf
, made it possible to see from pg_stat_activity when a backend was stuck waiting for another backend, but it's also fairly common for a backend to be stuck waiting for an I/O. Add wait events for those operations, too. Rushabh Lathia, with further hacking by me. Reviewed and tested by Michael Paquier, Amit Kapila, Rajkumar Raghuwanshi, and Rahila Syed. Discussion: http://postgr.es/m/CAGPqQf0LsYHXREPAZqYGVkDqHSyjf=KsD=k0GTVPAuzyThh-VQ@mail.gmail.com
This commit is contained in:
@ -58,6 +58,7 @@
|
||||
#include "catalog/catalog.h"
|
||||
#include "lib/binaryheap.h"
|
||||
#include "miscadmin.h"
|
||||
#include "pgstat.h"
|
||||
#include "replication/logical.h"
|
||||
#include "replication/reorderbuffer.h"
|
||||
#include "replication/slot.h"
|
||||
@ -2275,6 +2276,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
|
||||
ondisk->size = sz;
|
||||
|
||||
pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_WRITE);
|
||||
if (write(fd, rb->outbuf, ondisk->size) != ondisk->size)
|
||||
{
|
||||
int save_errno = errno;
|
||||
@ -2286,6 +2288,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
errmsg("could not write to data file for XID %u: %m",
|
||||
txn->xid)));
|
||||
}
|
||||
pgstat_report_wait_end();
|
||||
|
||||
Assert(ondisk->change.action == change->action);
|
||||
}
|
||||
@ -2366,7 +2369,9 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
* end of this file.
|
||||
*/
|
||||
ReorderBufferSerializeReserve(rb, sizeof(ReorderBufferDiskChange));
|
||||
pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_READ);
|
||||
readBytes = read(*fd, rb->outbuf, sizeof(ReorderBufferDiskChange));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
/* eof */
|
||||
if (readBytes == 0)
|
||||
@ -2393,8 +2398,10 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
sizeof(ReorderBufferDiskChange) + ondisk->size);
|
||||
ondisk = (ReorderBufferDiskChange *) rb->outbuf;
|
||||
|
||||
pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_READ);
|
||||
readBytes = read(*fd, rb->outbuf + sizeof(ReorderBufferDiskChange),
|
||||
ondisk->size - sizeof(ReorderBufferDiskChange));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (readBytes < 0)
|
||||
ereport(ERROR,
|
||||
@ -3047,7 +3054,9 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
|
||||
memset(&key, 0, sizeof(ReorderBufferTupleCidKey));
|
||||
|
||||
/* read all mappings till the end of the file */
|
||||
pgstat_report_wait_start(WAIT_EVENT_REORDER_LOGICAL_MAPPING_READ);
|
||||
readBytes = read(fd, &map, sizeof(LogicalRewriteMappingData));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (readBytes < 0)
|
||||
ereport(ERROR,
|
||||
|
Reference in New Issue
Block a user