mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Change ProcSendSignal() to take pgprocno.
Instead of referring to target backends by pid, use pgprocno. This means that we don't have to scan the ProcArray and we can drop some special case code for dealing with the startup process. Discussion: https://postgr.es/m/CA%2BhUKGLYRyDaneEwz5Uya_OgFLMx5BgJfkQSD%3Dq9HmwsfRRb-w%40mail.gmail.com Reviewed-by: Soumyadeep Chakraborty <soumyadeep2007@gmail.com> Reviewed-by: Ashwin Agrawal <ashwinstar@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de>
This commit is contained in:
@@ -136,7 +136,7 @@ typedef struct buftag
|
||||
* BufferDesc -- shared descriptor/state data for a single shared buffer.
|
||||
*
|
||||
* Note: Buffer header lock (BM_LOCKED flag) must be held to examine or change
|
||||
* the tag, state or wait_backend_pid fields. In general, buffer header lock
|
||||
* tag, state or wait_backend_pgprocno fields. In general, buffer header lock
|
||||
* is a spinlock which is combined with flags, refcount and usagecount into
|
||||
* single atomic variable. This layout allow us to do some operations in a
|
||||
* single atomic operation, without actually acquiring and releasing spinlock;
|
||||
@@ -161,8 +161,8 @@ typedef struct buftag
|
||||
*
|
||||
* We can't physically remove items from a disk page if another backend has
|
||||
* the buffer pinned. Hence, a backend may need to wait for all other pins
|
||||
* to go away. This is signaled by storing its own PID into
|
||||
* wait_backend_pid and setting flag bit BM_PIN_COUNT_WAITER. At present,
|
||||
* to go away. This is signaled by storing its own pgprocno into
|
||||
* wait_backend_pgprocno and setting flag bit BM_PIN_COUNT_WAITER. At present,
|
||||
* there can be only one such waiter per buffer.
|
||||
*
|
||||
* We use this same struct for local buffer headers, but the locks are not
|
||||
@@ -187,7 +187,7 @@ typedef struct BufferDesc
|
||||
/* state of the tag, containing flags, refcount and usagecount */
|
||||
pg_atomic_uint32 state;
|
||||
|
||||
int wait_backend_pid; /* backend PID of pin-count waiter */
|
||||
int wait_backend_pgprocno; /* backend of pin-count waiter */
|
||||
int freeNext; /* link in freelist chain */
|
||||
LWLock content_lock; /* to lock access to buffer contents */
|
||||
} BufferDesc;
|
||||
|
||||
@@ -113,6 +113,7 @@ typedef struct SERIALIZABLEXACT
|
||||
TransactionId xmin; /* the transaction's snapshot xmin */
|
||||
uint32 flags; /* OR'd combination of values defined below */
|
||||
int pid; /* pid of associated process */
|
||||
int pgprocno; /* pgprocno of associated process */
|
||||
} SERIALIZABLEXACT;
|
||||
|
||||
#define SXACT_FLAG_COMMITTED 0x00000001 /* already committed */
|
||||
|
||||
@@ -359,9 +359,6 @@ typedef struct PROC_HDR
|
||||
Latch *checkpointerLatch;
|
||||
/* Current shared estimate of appropriate spins_per_delay value */
|
||||
int spins_per_delay;
|
||||
/* The proc of the Startup process, since not in ProcArray */
|
||||
PGPROC *startupProc;
|
||||
int startupProcPid;
|
||||
/* Buffer id of the buffer that Startup process waits for pin on, or -1 */
|
||||
int startupBufferPinWaitBufId;
|
||||
} PROC_HDR;
|
||||
@@ -402,7 +399,6 @@ extern void InitProcess(void);
|
||||
extern void InitProcessPhase2(void);
|
||||
extern void InitAuxiliaryProcess(void);
|
||||
|
||||
extern void PublishStartupProcessInformation(void);
|
||||
extern void SetStartupBufferPinWaitBufId(int bufid);
|
||||
extern int GetStartupBufferPinWaitBufId(void);
|
||||
|
||||
@@ -418,7 +414,7 @@ extern bool IsWaitingForLock(void);
|
||||
extern void LockErrorCleanup(void);
|
||||
|
||||
extern void ProcWaitForSignal(uint32 wait_event_info);
|
||||
extern void ProcSendSignal(int pid);
|
||||
extern void ProcSendSignal(int pgprocno);
|
||||
|
||||
extern PGPROC *AuxiliaryPidGetProc(int pid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user