Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16a4e4a

Browse files
committed
Extend the ProcSignal mechanism to support barriers.
A new function EmitProcSignalBarrier() can be used to emit a globalbarrier which all backends that participate in the ProcSignalmechanism must absorb, and a new function WaitForProcSignalBarrier()can be used to wait until all relevant backends have in factabsorbed the barrier.This can be used to coordinate global state changes, such as turningchecksums on while the system is running.There's no real client of this mechanism yet, although two areproposed, but an enum has to have at least one element, so thisincludes a placeholder type (PROCSIGNAL_BARRIER_PLACEHOLDER) whichshould be replaced by the first real client of this mechanism toget committed.Andres Freund and Robert Haas, reviewed by Daniel Gustafsson and,in earlier versions, by Magnus Hagander.Discussion:http://postgr.es/m/CA+TgmoZwDk=BguVDVa+qdA6SBKef=PKbaKDQALTC_9qoz1mJqg@mail.gmail.com
1 parent9f83468 commit16a4e4a

File tree

14 files changed

+350
-14
lines changed

14 files changed

+350
-14
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
14731473
<entry>Waiting to apply WAL at recovery because it is delayed.</entry>
14741474
</row>
14751475
<row>
1476-
<entry morerows="66"><literal>IO</literal></entry>
1476+
<entry morerows="67"><literal>IO</literal></entry>
14771477
<entry><literal>BufFileRead</literal></entry>
14781478
<entry>Waiting for a read from a buffered file.</entry>
14791479
</row>
@@ -1593,6 +1593,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
15931593
<entry><literal>LogicalRewriteWrite</literal></entry>
15941594
<entry>Waiting for a write of logical rewrite mappings.</entry>
15951595
</row>
1596+
<row>
1597+
<entry><literal>ProcSignalBarrier</literal></entry>
1598+
<entry>Waiting for a barrier event to be processed by all backends.</entry>
1599+
</row>
15961600
<row>
15971601
<entry><literal>RelationMapRead</literal></entry>
15981602
<entry>Waiting for a read of the relation map file.</entry>

‎src/backend/postmaster/autovacuum.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,10 @@ HandleAutoVacLauncherInterrupts(void)
820820
rebuild_database_list(InvalidOid);
821821
}
822822

823+
/* Process barrier events */
824+
if (ProcSignalBarrierPending)
825+
ProcessProcSignalBarrier();
826+
823827
/* Process sinval catchup interrupts that happened while sleeping */
824828
ProcessCatchupInterrupt();
825829
}

‎src/backend/postmaster/checkpointer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ CheckpointerMain(void)
524524
staticvoid
525525
HandleCheckpointerInterrupts(void)
526526
{
527+
if (ProcSignalBarrierPending)
528+
ProcessProcSignalBarrier();
529+
527530
if (ConfigReloadPending)
528531
{
529532
ConfigReloadPending= false;
@@ -710,6 +713,10 @@ CheckpointWriteDelay(int flags, double progress)
710713
AbsorbSyncRequests();
711714
absorb_counter=WRITES_PER_ABSORB;
712715
}
716+
717+
/* Check for barrier events. */
718+
if (ProcSignalBarrierPending)
719+
ProcessProcSignalBarrier();
713720
}
714721

715722
/*

‎src/backend/postmaster/interrupt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include"postmaster/interrupt.h"
2121
#include"storage/ipc.h"
2222
#include"storage/latch.h"
23+
#include"storage/procsignal.h"
2324
#include"utils/guc.h"
2425

2526
volatilesig_atomic_tConfigReloadPending= false;
@@ -31,6 +32,9 @@ volatile sig_atomic_t ShutdownRequestPending = false;
3132
void
3233
HandleMainLoopInterrupts(void)
3334
{
35+
if (ProcSignalBarrierPending)
36+
ProcessProcSignalBarrier();
37+
3438
if (ConfigReloadPending)
3539
{
3640
ConfigReloadPending= false;

‎src/backend/postmaster/pgstat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,6 +3988,9 @@ pgstat_get_wait_io(WaitEventIO w)
39883988
caseWAIT_EVENT_LOGICAL_REWRITE_WRITE:
39893989
event_name="LogicalRewriteWrite";
39903990
break;
3991+
caseWAIT_EVENT_PROC_SIGNAL_BARRIER:
3992+
event_name="ProcSignalBarrier";
3993+
break;
39913994
caseWAIT_EVENT_RELATION_MAP_READ:
39923995
event_name="RelationMapRead";
39933996
break;

‎src/backend/postmaster/startup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ StartupProcShutdownHandler(SIGNAL_ARGS)
9696
errno=save_errno;
9797
}
9898

99-
/* HandleSIGHUP and SIGTERM signals of startup process */
99+
/* Handlevarious signals that might be sent to the startup process */
100100
void
101101
HandleStartupProcInterrupts(void)
102102
{
@@ -121,6 +121,10 @@ HandleStartupProcInterrupts(void)
121121
*/
122122
if (IsUnderPostmaster&& !PostmasterIsAlive())
123123
exit(1);
124+
125+
/* Process barrier events */
126+
if (ProcSignalBarrierPending)
127+
ProcessProcSignalBarrier();
124128
}
125129

126130

‎src/backend/replication/walreceiver.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ ProcessWalRcvInterrupts(void)
148148
/*
149149
* Although walreceiver interrupt handling doesn't use the same scheme as
150150
* regular backends, call CHECK_FOR_INTERRUPTS() to make sure we receive
151-
* any incoming signals on Win32.
151+
* any incoming signals on Win32, and also to make sure we process any
152+
* barrier events.
152153
*/
153154
CHECK_FOR_INTERRUPTS();
154155

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,10 @@ BufferSync(int flags)
18521852
}
18531853

18541854
UnlockBufHdr(bufHdr,buf_state);
1855+
1856+
/* Check for barrier events in case NBuffers is large. */
1857+
if (ProcSignalBarrierPending)
1858+
ProcessProcSignalBarrier();
18551859
}
18561860

18571861
if (num_to_scan==0)
@@ -1930,6 +1934,10 @@ BufferSync(int flags)
19301934
}
19311935

19321936
s->num_to_scan++;
1937+
1938+
/* Check for barrier events. */
1939+
if (ProcSignalBarrierPending)
1940+
ProcessProcSignalBarrier();
19331941
}
19341942

19351943
Assert(num_spaces>0);
@@ -2018,6 +2026,8 @@ BufferSync(int flags)
20182026

20192027
/*
20202028
* Sleep to throttle our I/O rate.
2029+
*
2030+
* (This will check for barrier events even if it doesn't sleep.)
20212031
*/
20222032
CheckpointWriteDelay(flags, (double)num_processed /num_to_scan);
20232033
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp