From: Andres Freund Date: Mon, 24 Oct 2022 16:44:16 -0700 Subject: [PATCH v5 08/15] bufmgr: Support multiple in-progress IOs by using resowner Commit message should describe why we couldn't support multiple in-progress IOs before, I think (e.g. we couldn't be sure that we cleared IO_IN_PROGRESS if something happened). @@ -4709,8 +4704,6 @@ TerminateBufferIO(BufferDesc *buf, bool clear_dirty, uint32 set_flag_bits) { uint32 buf_state; I noticed that the comment above TermianteBufferIO() says * TerminateBufferIO: release a buffer we were doing I/O on * (Assumptions) * My process is executing IO for the buffer Can we still say this is an assumption? What about when it is being cleaned up after being called from AbortBufferIO() diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c index 19b6241e45..fccc59b39d 100644 --- a/src/backend/utils/resowner/resowner.c +++ b/src/backend/utils/resowner/resowner.c @@ -121,6 +121,7 @@ typedef struct ResourceOwnerData /* We have built-in support for remembering: */ ResourceArray bufferarr; /* owned buffers */ + ResourceArray bufferioarr; /* in-progress buffer IO */ ResourceArray catrefarr; /* catcache references */ ResourceArray catlistrefarr; /* catcache-list pins */ ResourceArray relrefarr; /* relcache references */ @@ -441,6 +442,7 @@ ResourceOwnerCreate(ResourceOwner parent, const char *name) Maybe worth mentioning in-progress buffer IO in resowner README? I know it doesn't claim to be exhaustive, so, up to you. Also, I realize that existing code in this file has the extraneous parantheses, but maybe it isn't worth staying consistent with that? as in: &(owner->bufferioarr) + */ +void +ResourceOwnerRememberBufferIO(ResourceOwner owner, Buffer buffer) +{ + ResourceArrayAdd(&(owner->bufferioarr), BufferGetDatum(buffer)); +} +