PostgreSQL Source Code git master
Loading...
Searching...
No Matches
procsignal.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * procsignal.c
4 * Routines for interprocess signaling
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * IDENTIFICATION
11 * src/backend/storage/ipc/procsignal.c
12 *
13 *-------------------------------------------------------------------------
14 */
15#include "postgres.h"
16
17#include <signal.h>
18#include <unistd.h>
19
20#include "access/parallel.h"
21#include "commands/async.h"
22#include "miscadmin.h"
23#include "pgstat.h"
24#include "port/pg_bitutils.h"
29#include "storage/ipc.h"
30#include "storage/latch.h"
31#include "storage/proc.h"
32#include "storage/shmem.h"
33#include "storage/sinval.h"
34#include "storage/smgr.h"
35#include "tcop/tcopprot.h"
36#include "utils/memutils.h"
37
38/*
39 * The SIGUSR1 signal is multiplexed to support signaling multiple event
40 * types. The specific reason is communicated via flags in shared memory.
41 * We keep a boolean flag for each possible "reason", so that different
42 * reasons can be signaled to a process concurrently. (However, if the same
43 * reason is signaled more than once nearly simultaneously, the process may
44 * observe it only once.)
45 *
46 * Each process that wants to receive signals registers its process ID
47 * in the ProcSignalSlots array. The array is indexed by ProcNumber to make
48 * slot allocation simple, and to avoid having to search the array when you
49 * know the ProcNumber of the process you're signaling. (We do support
50 * signaling without ProcNumber, but it's a bit less efficient.)
51 *
52 * The fields in each slot are protected by a spinlock, pss_mutex. pss_pid can
53 * also be read without holding the spinlock, as a quick preliminary check
54 * when searching for a particular PID in the array.
55 *
56 * pss_signalFlags are intended to be set in cases where we don't need to
57 * keep track of whether or not the target process has handled the signal,
58 * but sometimes we need confirmation, as when making a global state change
59 * that cannot be considered complete until all backends have taken notice
60 * of it. For such use cases, we set a bit in pss_barrierCheckMask and then
61 * increment the current "barrier generation"; when the new barrier generation
62 * (or greater) appears in the pss_barrierGeneration flag of every process,
63 * we know that the message has been received everywhere.
64 */
65typedef struct
66{
68 int pss_cancel_key_len; /* 0 means no cancellation is possible */
70 volatile sig_atomic_t pss_signalFlags[NUM_PROCSIGNALS];
71 slock_t pss_mutex; /* protects the above fields */
72
73 /* Barrier-related fields (not protected by pss_mutex) */
78
79/*
80 * Information that is global to the entire ProcSignal system can be stored
81 * here.
82 *
83 * psh_barrierGeneration is the highest barrier generation in existence.
84 */
90
91/*
92 * We reserve a slot for each possible ProcNumber, plus one for each
93 * possible auxiliary process type. (This scheme assumes there is not
94 * more than one of any auxiliary process type at a time, except for
95 * IO workers.)
96 */
97#define NumProcSignalSlots (MaxBackends + NUM_AUXILIARY_PROCS)
98
99/* Check whether the relevant type bit is set in the flags. */
100#define BARRIER_SHOULD_CHECK(flags, type) \
101 (((flags) & (((uint32) 1) << (uint32) (type))) != 0)
102
103/* Clear the relevant type bit from the flags. */
104#define BARRIER_CLEAR_BIT(flags, type) \
105 ((flags) &= ~(((uint32) 1) << (uint32) (type)))
106
109
110static bool CheckProcSignal(ProcSignalReason reason);
111static void CleanupProcSignalState(int status, Datum arg);
112static void ResetProcSignalBarrierBits(uint32 flags);
113
114/*
115 * ProcSignalShmemSize
116 * Compute space needed for ProcSignal's shared memory
117 */
118Size
120{
121 Size size;
122
124 size = add_size(size, offsetof(ProcSignalHeader, psh_slot));
125 return size;
126}
127
128/*
129 * ProcSignalShmemInit
130 * Allocate and initialize ProcSignal's shared memory
131 */
132void
134{
135 Size size = ProcSignalShmemSize();
136 bool found;
137
139 ShmemInitStruct("ProcSignal", size, &found);
140
141 /* If we're first, initialize. */
142 if (!found)
143 {
144 int i;
145
147
148 for (i = 0; i < NumProcSignalSlots; ++i)
149 {
151
152 SpinLockInit(&slot->pss_mutex);
153 pg_atomic_init_u32(&slot->pss_pid, 0);
154 slot->pss_cancel_key_len = 0;
155 MemSet(slot->pss_signalFlags, 0, sizeof(slot->pss_signalFlags));
159 }
160 }
161}
162
163/*
164 * ProcSignalInit
165 * Register the current process in the ProcSignal array
166 */
167void
169{
170 ProcSignalSlot *slot;
173
175 if (MyProcNumber < 0)
176 elog(ERROR, "MyProcNumber not set");
178 elog(ERROR, "unexpected MyProcNumber %d in ProcSignalInit (max %d)", MyProcNumber, NumProcSignalSlots);
180
182
183 /* Value used for sanity check below */
185
186 /* Clear out any leftover signal reasons */
188
189 /*
190 * Initialize barrier state. Since we're a brand-new process, there
191 * shouldn't be any leftover backend-private state that needs to be
192 * updated. Therefore, we can broadcast the latest barrier generation and
193 * disregard any previously-set check bits.
194 *
195 * NB: This only works if this initialization happens early enough in the
196 * startup sequence that we haven't yet cached any state that might need
197 * to be invalidated. That's also why we have a memory barrier here, to be
198 * sure that any later reads of memory happen strictly after this.
199 */
204
205 if (cancel_key_len > 0)
209
211
212 /* Spinlock is released, do the check */
213 if (old_pss_pid != 0)
214 elog(LOG, "process %d taking over ProcSignal slot %d, but it's not empty",
216
217 /* Remember slot location for CheckProcSignal */
218 MyProcSignalSlot = slot;
219
220 /* Set up to release the slot on process exit */
222}
223
224/*
225 * CleanupProcSignalState
226 * Remove current process from ProcSignal mechanism
227 *
228 * This function is called via on_shmem_exit() during backend shutdown.
229 */
230static void
232{
235
236 /*
237 * Clear MyProcSignalSlot, so that a SIGUSR1 received after this point
238 * won't try to access it after it's no longer ours (and perhaps even
239 * after we've unmapped the shared memory segment).
240 */
243
244 /* sanity check */
247 if (old_pid != MyProcPid)
248 {
249 /*
250 * don't ERROR here. We're exiting anyway, and don't want to get into
251 * infinite loop trying to exit
252 */
254 elog(LOG, "process %d releasing ProcSignal slot %d, but it contains %d",
255 MyProcPid, (int) (slot - ProcSignal->psh_slot), (int) old_pid);
256 return; /* XXX better to zero the slot anyway? */
257 }
258
259 /* Mark the slot as unused */
260 pg_atomic_write_u32(&slot->pss_pid, 0);
261 slot->pss_cancel_key_len = 0;
262
263 /*
264 * Make this slot look like it's absorbed all possible barriers, so that
265 * no barrier waits block on it.
266 */
268
270
272}
273
274/*
275 * SendProcSignal
276 * Send a signal to a Postgres process
277 *
278 * Providing procNumber is optional, but it will speed up the operation.
279 *
280 * On success (a signal was sent), zero is returned.
281 * On error, -1 is returned, and errno is set (typically to ESRCH or EPERM).
282 *
283 * Not to be confused with ProcSendSignal
284 */
285int
287{
288 volatile ProcSignalSlot *slot;
289
290 if (procNumber != INVALID_PROC_NUMBER)
291 {
292 Assert(procNumber < NumProcSignalSlots);
293 slot = &ProcSignal->psh_slot[procNumber];
294
296 if (pg_atomic_read_u32(&slot->pss_pid) == pid)
297 {
298 /* Atomically set the proper flag */
299 slot->pss_signalFlags[reason] = true;
301 /* Send signal */
302 return kill(pid, SIGUSR1);
303 }
305 }
306 else
307 {
308 /*
309 * procNumber not provided, so search the array using pid. We search
310 * the array back to front so as to reduce search overhead. Passing
311 * INVALID_PROC_NUMBER means that the target is most likely an
312 * auxiliary process, which will have a slot near the end of the
313 * array.
314 */
315 int i;
316
317 for (i = NumProcSignalSlots - 1; i >= 0; i--)
318 {
319 slot = &ProcSignal->psh_slot[i];
320
321 if (pg_atomic_read_u32(&slot->pss_pid) == pid)
322 {
324 if (pg_atomic_read_u32(&slot->pss_pid) == pid)
325 {
326 /* Atomically set the proper flag */
327 slot->pss_signalFlags[reason] = true;
329 /* Send signal */
330 return kill(pid, SIGUSR1);
331 }
333 }
334 }
335 }
336
337 errno = ESRCH;
338 return -1;
339}
340
341/*
342 * EmitProcSignalBarrier
343 * Send a signal to every Postgres process
344 *
345 * The return value of this function is the barrier "generation" created
346 * by this operation. This value can be passed to WaitForProcSignalBarrier
347 * to wait until it is known that every participant in the ProcSignal
348 * mechanism has absorbed the signal (or started afterwards).
349 *
350 * Note that it would be a bad idea to use this for anything that happens
351 * frequently, as interrupting every backend could cause a noticeable
352 * performance hit.
353 *
354 * Callers are entitled to assume that this function will not throw ERROR
355 * or FATAL.
356 */
357uint64
359{
360 uint32 flagbit = 1 << (uint32) type;
361 uint64 generation;
362
363 /*
364 * Set all the flags.
365 *
366 * Note that pg_atomic_fetch_or_u32 has full barrier semantics, so this is
367 * totally ordered with respect to anything the caller did before, and
368 * anything that we do afterwards. (This is also true of the later call to
369 * pg_atomic_add_fetch_u64.)
370 */
371 for (int i = 0; i < NumProcSignalSlots; i++)
372 {
373 volatile ProcSignalSlot *slot = &ProcSignal->psh_slot[i];
374
376 }
377
378 /*
379 * Increment the generation counter.
380 */
381 generation =
383
384 /*
385 * Signal all the processes, so that they update their advertised barrier
386 * generation.
387 *
388 * Concurrency is not a problem here. Backends that have exited don't
389 * matter, and new backends that have joined since we entered this
390 * function must already have current state, since the caller is
391 * responsible for making sure that the relevant state is entirely visible
392 * before calling this function in the first place. We still have to wake
393 * them up - because we can't distinguish between such backends and older
394 * backends that need to update state - but they won't actually need to
395 * change any state.
396 */
397 for (int i = NumProcSignalSlots - 1; i >= 0; i--)
398 {
399 volatile ProcSignalSlot *slot = &ProcSignal->psh_slot[i];
400 pid_t pid = pg_atomic_read_u32(&slot->pss_pid);
401
402 if (pid != 0)
403 {
405 pid = pg_atomic_read_u32(&slot->pss_pid);
406 if (pid != 0)
407 {
408 /* see SendProcSignal for details */
409 slot->pss_signalFlags[PROCSIG_BARRIER] = true;
411 kill(pid, SIGUSR1);
412 }
413 else
415 }
416 }
417
418 return generation;
419}
420
421/*
422 * WaitForProcSignalBarrier - wait until it is guaranteed that all changes
423 * requested by a specific call to EmitProcSignalBarrier() have taken effect.
424 */
425void
427{
429
430 elog(DEBUG1,
431 "waiting for all backends to process ProcSignalBarrier generation "
433 generation);
434
435 for (int i = NumProcSignalSlots - 1; i >= 0; i--)
436 {
439
440 /*
441 * It's important that we check only pss_barrierGeneration here and
442 * not pss_barrierCheckMask. Bits in pss_barrierCheckMask get cleared
443 * before the barrier is actually absorbed, but pss_barrierGeneration
444 * is updated only afterward.
445 */
447 while (oldval < generation)
448 {
450 5000,
452 ereport(LOG,
453 (errmsg("still waiting for backend with PID %d to accept ProcSignalBarrier",
454 (int) pg_atomic_read_u32(&slot->pss_pid))));
456 }
458 }
459
460 elog(DEBUG1,
461 "finished waiting for all backends to process ProcSignalBarrier generation "
463 generation);
464
465 /*
466 * The caller is probably calling this function because it wants to read
467 * the shared state or perform further writes to shared state once all
468 * backends are known to have absorbed the barrier. However, the read of
469 * pss_barrierGeneration was performed unlocked; insert a memory barrier
470 * to separate it from whatever follows.
471 */
473}
474
475/*
476 * Handle receipt of an interrupt indicating a global barrier event.
477 *
478 * All the actual work is deferred to ProcessProcSignalBarrier(), because we
479 * cannot safely access the barrier generation inside the signal handler as
480 * 64bit atomics might use spinlock based emulation, even for reads. As this
481 * routine only gets called when PROCSIG_BARRIER is sent that won't cause a
482 * lot of unnecessary work.
483 */
484static void
486{
487 InterruptPending = true;
489 /* latch will be set by procsignal_sigusr1_handler */
490}
491
492/*
493 * Perform global barrier related interrupt checking.
494 *
495 * Any backend that participates in ProcSignal signaling must arrange to
496 * call this function periodically. It is called from CHECK_FOR_INTERRUPTS(),
497 * which is enough for normal backends, but not necessarily for all types of
498 * background processes.
499 */
500void
502{
505 volatile uint32 flags;
506
508
509 /* Exit quickly if there's no work to do. */
511 return;
513
514 /*
515 * It's not unlikely to process multiple barriers at once, before the
516 * signals for all the barriers have arrived. To avoid unnecessary work in
517 * response to subsequent signals, exit early if we already have processed
518 * all of them.
519 */
522
524
525 if (local_gen == shared_gen)
526 return;
527
528 /*
529 * Get and clear the flags that are set for this backend. Note that
530 * pg_atomic_exchange_u32 is a full barrier, so we're guaranteed that the
531 * read of the barrier generation above happens before we atomically
532 * extract the flags, and that any subsequent state changes happen
533 * afterward.
534 *
535 * NB: In order to avoid race conditions, we must zero
536 * pss_barrierCheckMask first and only afterwards try to do barrier
537 * processing. If we did it in the other order, someone could send us
538 * another barrier of some type right after we called the
539 * barrier-processing function but before we cleared the bit. We would
540 * have no way of knowing that the bit needs to stay set in that case, so
541 * the need to call the barrier-processing function again would just get
542 * forgotten. So instead, we tentatively clear all the bits and then put
543 * back any for which we don't manage to successfully absorb the barrier.
544 */
546
547 /*
548 * If there are no flags set, then we can skip doing any real work.
549 * Otherwise, establish a PG_TRY block, so that we don't lose track of
550 * which types of barrier processing are needed if an ERROR occurs.
551 */
552 if (flags != 0)
553 {
554 bool success = true;
555
556 PG_TRY();
557 {
558 /*
559 * Process each type of barrier. The barrier-processing functions
560 * should normally return true, but may return false if the
561 * barrier can't be absorbed at the current time. This should be
562 * rare, because it's pretty expensive. Every single
563 * CHECK_FOR_INTERRUPTS() will return here until we manage to
564 * absorb the barrier, and that cost will add up in a hurry.
565 *
566 * NB: It ought to be OK to call the barrier-processing functions
567 * unconditionally, but it's more efficient to call only the ones
568 * that might need us to do something based on the flags.
569 */
570 while (flags != 0)
571 {
573 bool processed = true;
574
576 switch (type)
577 {
579 processed = ProcessBarrierSmgrRelease();
580 break;
583 break;
584 }
585
586 /*
587 * To avoid an infinite loop, we must always unset the bit in
588 * flags.
589 */
590 BARRIER_CLEAR_BIT(flags, type);
591
592 /*
593 * If we failed to process the barrier, reset the shared bit
594 * so we try again later, and set a flag so that we don't bump
595 * our generation.
596 */
597 if (!processed)
598 {
600 success = false;
601 }
602 }
603 }
604 PG_CATCH();
605 {
606 /*
607 * If an ERROR occurred, we'll need to try again later to handle
608 * that barrier type and any others that haven't been handled yet
609 * or weren't successfully absorbed.
610 */
612 PG_RE_THROW();
613 }
614 PG_END_TRY();
615
616 /*
617 * If some barrier types were not successfully absorbed, we will have
618 * to try again later.
619 */
620 if (!success)
621 return;
622 }
623
624 /*
625 * State changes related to all types of barriers that might have been
626 * emitted have now been handled, so we can update our notion of the
627 * generation to the one we observed before beginning the updates. If
628 * things have changed further, it'll get fixed up when this function is
629 * next called.
630 */
633}
634
635/*
636 * If it turns out that we couldn't absorb one or more barrier types, either
637 * because the barrier-processing functions returned false or due to an error,
638 * arrange for processing to be retried later.
639 */
640static void
647
648/*
649 * CheckProcSignal - check to see if a particular reason has been
650 * signaled, and clear the signal flag. Should be called after receiving
651 * SIGUSR1.
652 */
653static bool
655{
656 volatile ProcSignalSlot *slot = MyProcSignalSlot;
657
658 if (slot != NULL)
659 {
660 /*
661 * Careful here --- don't clear flag if we haven't seen it set.
662 * pss_signalFlags is of type "volatile sig_atomic_t" to allow us to
663 * read it here safely, without holding the spinlock.
664 */
665 if (slot->pss_signalFlags[reason])
666 {
667 slot->pss_signalFlags[reason] = false;
668 return true;
669 }
670 }
671
672 return false;
673}
674
675/*
676 * procsignal_sigusr1_handler - handle SIGUSR1 signal.
677 */
678void
707
708/*
709 * Send a query cancellation signal to backend.
710 *
711 * Note: This is called from a backend process before authentication. We
712 * cannot take LWLocks yet, but that's OK; we rely on atomic reads of the
713 * fields in the ProcSignal slots.
714 */
715void
717{
718 if (backendPID == 0)
719 {
720 ereport(LOG, (errmsg("invalid cancel request with PID 0")));
721 return;
722 }
723
724 /*
725 * See if we have a matching backend. Reading the pss_pid and
726 * pss_cancel_key fields is racy, a backend might die and remove itself
727 * from the array at any time. The probability of the cancellation key
728 * matching wrong process is miniscule, however, so we can live with that.
729 * PIDs are reused too, so sending the signal based on PID is inherently
730 * racy anyway, although OS's avoid reusing PIDs too soon.
731 */
732 for (int i = 0; i < NumProcSignalSlots; i++)
733 {
735 bool match;
736
737 if (pg_atomic_read_u32(&slot->pss_pid) != backendPID)
738 continue;
739
740 /* Acquire the spinlock and re-check */
742 if (pg_atomic_read_u32(&slot->pss_pid) != backendPID)
743 {
745 continue;
746 }
747 else
748 {
749 match = slot->pss_cancel_key_len == cancel_key_len &&
751
753
754 if (match)
755 {
756 /* Found a match; signal that backend to cancel current op */
758 (errmsg_internal("processing cancel request: sending SIGINT to process %d",
759 backendPID)));
760
761 /*
762 * If we have setsid(), signal the backend's whole process
763 * group
764 */
765#ifdef HAVE_SETSID
766 kill(-backendPID, SIGINT);
767#else
768 kill(backendPID, SIGINT);
769#endif
770 }
771 else
772 {
773 /* Right PID, wrong key: no way, Jose */
774 ereport(LOG,
775 (errmsg("wrong key in cancel request for process %d",
776 backendPID)));
777 }
778 return;
779 }
780 }
781
782 /* No matching backend */
783 ereport(LOG,
784 (errmsg("PID %d in cancel request did not match any process",
785 backendPID)));
786}
void HandleParallelApplyMessageInterrupt(void)
void HandleNotifyInterrupt(void)
Definition async.c:2543
static void pg_atomic_write_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition atomics.h:485
static uint32 pg_atomic_fetch_or_u32(volatile pg_atomic_uint32 *ptr, uint32 or_)
Definition atomics.h:410
#define pg_memory_barrier()
Definition atomics.h:141
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:219
static void pg_atomic_write_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:274
static uint32 pg_atomic_read_u32(volatile pg_atomic_uint32 *ptr)
Definition atomics.h:237
static uint64 pg_atomic_add_fetch_u64(volatile pg_atomic_uint64 *ptr, int64 add_)
Definition atomics.h:569
static uint32 pg_atomic_exchange_u32(volatile pg_atomic_uint32 *ptr, uint32 newval)
Definition atomics.h:330
static void pg_atomic_init_u64(volatile pg_atomic_uint64 *ptr, uint64 val)
Definition atomics.h:453
static uint64 pg_atomic_read_u64(volatile pg_atomic_uint64 *ptr)
Definition atomics.h:467
void HandleParallelMessageInterrupt(void)
Definition parallel.c:1045
uint8_t uint8
Definition c.h:577
#define SIGNAL_ARGS
Definition c.h:1406
#define Assert(condition)
Definition c.h:906
#define FLEXIBLE_ARRAY_MEMBER
Definition c.h:513
#define UINT64_FORMAT
Definition c.h:598
uint64_t uint64
Definition c.h:580
uint32_t uint32
Definition c.h:579
#define PG_UINT64_MAX
Definition c.h:640
#define MemSet(start, val, len)
Definition c.h:1056
size_t Size
Definition c.h:652
bool ConditionVariableCancelSleep(void)
bool ConditionVariableTimedSleep(ConditionVariable *cv, long timeout, uint32 wait_event_info)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
Datum arg
Definition elog.c:1322
int errmsg(const char *fmt,...)
Definition elog.c:1093
#define LOG
Definition elog.h:31
#define PG_RE_THROW()
Definition elog.h:405
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define PG_TRY(...)
Definition elog.h:372
#define DEBUG2
Definition elog.h:29
#define PG_END_TRY(...)
Definition elog.h:397
#define DEBUG1
Definition elog.h:30
#define ERROR
Definition elog.h:39
#define PG_CATCH(...)
Definition elog.h:382
#define elog(elevel,...)
Definition elog.h:226
#define ereport(elevel,...)
Definition elog.h:150
volatile sig_atomic_t ProcSignalBarrierPending
Definition globals.c:40
volatile sig_atomic_t InterruptPending
Definition globals.c:32
int MyProcPid
Definition globals.c:47
ProcNumber MyProcNumber
Definition globals.c:90
struct Latch * MyLatch
Definition globals.c:63
static bool success
Definition initdb.c:187
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition ipc.c:372
int i
Definition isn.c:77
void SetLatch(Latch *latch)
Definition latch.c:290
bool ProcessBarrierUpdateXLogLogicalInfo(void)
Definition logicalctl.c:187
void HandleLogMemoryContextInterrupt(void)
Definition mcxt.c:1323
static int pg_rightmost_one_pos32(uint32 word)
int timingsafe_bcmp(const void *b1, const void *b2, size_t n)
void HandleRecoveryConflictInterrupt(void)
Definition postgres.c:3074
uint64_t Datum
Definition postgres.h:70
#define NON_EXEC_STATIC
Definition postgres.h:570
static int fb(int x)
#define INVALID_PROC_NUMBER
Definition procnumber.h:26
int ProcNumber
Definition procnumber.h:24
static void CleanupProcSignalState(int status, Datum arg)
Definition procsignal.c:231
int SendProcSignal(pid_t pid, ProcSignalReason reason, ProcNumber procNumber)
Definition procsignal.c:286
void ProcSignalInit(const uint8 *cancel_key, int cancel_key_len)
Definition procsignal.c:168
void ProcSignalShmemInit(void)
Definition procsignal.c:133
#define NumProcSignalSlots
Definition procsignal.c:97
static bool CheckProcSignal(ProcSignalReason reason)
Definition procsignal.c:654
void ProcessProcSignalBarrier(void)
Definition procsignal.c:501
void WaitForProcSignalBarrier(uint64 generation)
Definition procsignal.c:426
NON_EXEC_STATIC ProcSignalHeader * ProcSignal
Definition procsignal.c:107
static void ResetProcSignalBarrierBits(uint32 flags)
Definition procsignal.c:641
void SendCancelRequest(int backendPID, const uint8 *cancel_key, int cancel_key_len)
Definition procsignal.c:716
uint64 EmitProcSignalBarrier(ProcSignalBarrierType type)
Definition procsignal.c:358
Size ProcSignalShmemSize(void)
Definition procsignal.c:119
static void HandleProcSignalBarrierInterrupt(void)
Definition procsignal.c:485
static ProcSignalSlot * MyProcSignalSlot
Definition procsignal.c:108
#define BARRIER_CLEAR_BIT(flags, type)
Definition procsignal.c:104
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:679
#define NUM_PROCSIGNALS
Definition procsignal.h:44
ProcSignalReason
Definition procsignal.h:31
@ PROCSIG_RECOVERY_CONFLICT
Definition procsignal.h:39
@ PROCSIG_PARALLEL_MESSAGE
Definition procsignal.h:34
@ PROCSIG_CATCHUP_INTERRUPT
Definition procsignal.h:32
@ PROCSIG_LOG_MEMORY_CONTEXT
Definition procsignal.h:37
@ PROCSIG_BARRIER
Definition procsignal.h:36
@ PROCSIG_WALSND_INIT_STOPPING
Definition procsignal.h:35
@ PROCSIG_PARALLEL_APPLY_MESSAGE
Definition procsignal.h:38
@ PROCSIG_NOTIFY_INTERRUPT
Definition procsignal.h:33
ProcSignalBarrierType
Definition procsignal.h:47
@ PROCSIGNAL_BARRIER_SMGRRELEASE
Definition procsignal.h:48
@ PROCSIGNAL_BARRIER_UPDATE_XLOG_LOGICAL_INFO
Definition procsignal.h:49
#define MAX_CANCEL_KEY_LENGTH
Definition procsignal.h:61
Size add_size(Size s1, Size s2)
Definition shmem.c:482
Size mul_size(Size s1, Size s2)
Definition shmem.c:497
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition shmem.c:378
void HandleCatchupInterrupt(void)
Definition sinval.c:154
bool ProcessBarrierSmgrRelease(void)
Definition smgr.c:1027
static void SpinLockRelease(volatile slock_t *lock)
Definition spin.h:62
static void SpinLockAcquire(volatile slock_t *lock)
Definition spin.h:56
static void SpinLockInit(volatile slock_t *lock)
Definition spin.h:50
ProcSignalSlot psh_slot[FLEXIBLE_ARRAY_MEMBER]
Definition procsignal.c:88
pg_atomic_uint64 psh_barrierGeneration
Definition procsignal.c:87
uint8 pss_cancel_key[MAX_CANCEL_KEY_LENGTH]
Definition procsignal.c:69
ConditionVariable pss_barrierCV
Definition procsignal.c:76
pg_atomic_uint64 pss_barrierGeneration
Definition procsignal.c:74
volatile sig_atomic_t pss_signalFlags[NUM_PROCSIGNALS]
Definition procsignal.c:70
slock_t pss_mutex
Definition procsignal.c:71
pg_atomic_uint32 pss_pid
Definition procsignal.c:67
int pss_cancel_key_len
Definition procsignal.c:68
pg_atomic_uint32 pss_barrierCheckMask
Definition procsignal.c:75
const char * type
void HandleWalSndInitStopping(void)
Definition walsender.c:3704
#define kill(pid, sig)
Definition win32_port.h:490
#define SIGUSR1
Definition win32_port.h:170