mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
Create and use wait events for read, write, and fsync operations.
Previous commits, notably53be0b1addand6f3bd98ebf, 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:
@@ -37,6 +37,7 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "executor/instrument.h"
|
||||
#include "pgstat.h"
|
||||
#include "storage/fd.h"
|
||||
#include "storage/buffile.h"
|
||||
#include "storage/buf_internals.h"
|
||||
@@ -254,7 +255,10 @@ BufFileLoadBuffer(BufFile *file)
|
||||
/*
|
||||
* Read whatever we can get, up to a full bufferload.
|
||||
*/
|
||||
file->nbytes = FileRead(thisfile, file->buffer, sizeof(file->buffer));
|
||||
file->nbytes = FileRead(thisfile,
|
||||
file->buffer,
|
||||
sizeof(file->buffer),
|
||||
WAIT_EVENT_BUFFILE_READ);
|
||||
if (file->nbytes < 0)
|
||||
file->nbytes = 0;
|
||||
file->offsets[file->curFile] += file->nbytes;
|
||||
@@ -317,7 +321,10 @@ BufFileDumpBuffer(BufFile *file)
|
||||
return; /* seek failed, give up */
|
||||
file->offsets[file->curFile] = file->curOffset;
|
||||
}
|
||||
bytestowrite = FileWrite(thisfile, file->buffer + wpos, bytestowrite);
|
||||
bytestowrite = FileWrite(thisfile,
|
||||
file->buffer + wpos,
|
||||
bytestowrite,
|
||||
WAIT_EVENT_BUFFILE_WRITE);
|
||||
if (bytestowrite <= 0)
|
||||
return; /* failed to write */
|
||||
file->offsets[file->curFile] += bytestowrite;
|
||||
|
||||
Reference in New Issue
Block a user