Commit 64638ccb authored by Fujii Masao's avatar Fujii Masao

Report waiting via PS while recovery is waiting for buffer pin in hot standby.

Previously while the startup process was waiting for the recovery conflict
with snapshot, tablespace or lock to be resolved, waiting was reported in
PS display, but not in the case of recovery conflict with buffer pin.
This commit makes the startup process in hot standby report waiting via PS
while waiting for the conflicts with other backends holding buffer pins to
be resolved.

Author: Masahiko Sawada
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/CA+fd4k4mXWTwfQLS3RPwGr4xnfAEs1ysFfgYHvmmoUgv6Zxvmg@mail.gmail.com
parent 246f136e
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "storage/proc.h" #include "storage/proc.h"
#include "storage/smgr.h" #include "storage/smgr.h"
#include "storage/standby.h" #include "storage/standby.h"
#include "utils/ps_status.h"
#include "utils/rel.h" #include "utils/rel.h"
#include "utils/resowner_private.h" #include "utils/resowner_private.h"
#include "utils/timestamp.h" #include "utils/timestamp.h"
...@@ -3616,6 +3617,7 @@ void ...@@ -3616,6 +3617,7 @@ void
LockBufferForCleanup(Buffer buffer) LockBufferForCleanup(Buffer buffer)
{ {
BufferDesc *bufHdr; BufferDesc *bufHdr;
char *new_status = NULL;
Assert(BufferIsValid(buffer)); Assert(BufferIsValid(buffer));
Assert(PinCountWaitBuf == NULL); Assert(PinCountWaitBuf == NULL);
...@@ -3650,6 +3652,13 @@ LockBufferForCleanup(Buffer buffer) ...@@ -3650,6 +3652,13 @@ LockBufferForCleanup(Buffer buffer)
{ {
/* Successfully acquired exclusive lock with pincount 1 */ /* Successfully acquired exclusive lock with pincount 1 */
UnlockBufHdr(bufHdr, buf_state); UnlockBufHdr(bufHdr, buf_state);
/* Report change to non-waiting status */
if (new_status)
{
set_ps_display(new_status);
pfree(new_status);
}
return; return;
} }
/* Failed, so mark myself as waiting for pincount 1 */ /* Failed, so mark myself as waiting for pincount 1 */
...@@ -3668,6 +3677,20 @@ LockBufferForCleanup(Buffer buffer) ...@@ -3668,6 +3677,20 @@ LockBufferForCleanup(Buffer buffer)
/* Wait to be signaled by UnpinBuffer() */ /* Wait to be signaled by UnpinBuffer() */
if (InHotStandby) if (InHotStandby)
{ {
/* Report change to waiting status */
if (update_process_title && new_status == NULL)
{
const char *old_status;
int len;
old_status = get_ps_display(&len);
new_status = (char *) palloc(len + 8 + 1);
memcpy(new_status, old_status, len);
strcpy(new_status + len, " waiting");
set_ps_display(new_status);
new_status[len] = '\0'; /* truncate off " waiting" */
}
/* Publish the bufid that Startup process waits on */ /* Publish the bufid that Startup process waits on */
SetStartupBufferPinWaitBufId(buffer - 1); SetStartupBufferPinWaitBufId(buffer - 1);
/* Set alarm and then wait to be signaled by UnpinBuffer() */ /* Set alarm and then wait to be signaled by UnpinBuffer() */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment