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

Commit44623f2

Browse files
author
Andrei Krichinin
committed
PostgreSQL 15: all shared memory requests in shmem_request_hook()
1 parentdeb86e3 commit44623f2

File tree

5 files changed

+125
-11
lines changed

5 files changed

+125
-11
lines changed

‎src/ddl.c‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ static void MtmFinishDDLCommand(void);
150150

151151
PG_FUNCTION_INFO_V1(mtm_make_table_local);
152152

153+
#ifPG_VERSION_NUM >=150000
154+
staticshmem_request_hook_typeprev_shmem_request_hook=NULL;
155+
staticvoidmtm_ddl_shmem_request(void);
156+
#endif
157+
153158
/*****************************************************************************
154159
*
155160
* Init
@@ -159,16 +164,14 @@ PG_FUNCTION_INFO_V1(mtm_make_table_local);
159164
void
160165
MtmDDLReplicationInit()
161166
{
162-
Sizesize=0;
163-
164-
size=add_size(size,sizeof(structDDLSharedState));
165-
size=add_size(size,hash_estimate_size(MULTIMASTER_MAX_LOCAL_TABLES,
166-
sizeof(Oid)));
167-
size=MAXALIGN(size);
168-
167+
#ifPG_VERSION_NUM >=150000
168+
prev_shmem_request_hook=shmem_request_hook;
169+
shmem_request_hook=mtm_ddl_shmem_request;
170+
#else
169171
RequestAddinShmemSpace(size);
170172

171173
RequestNamedLWLockTranche("mtm-ddl",1);
174+
#endif
172175

173176
PreviousExecutorStartHook=ExecutorStart_hook;
174177
ExecutorStart_hook=MtmExecutorStart;
@@ -183,6 +186,25 @@ MtmDDLReplicationInit()
183186
SeqNextvalHook=MtmSeqNextvalHook;
184187
}
185188

189+
#ifPG_VERSION_NUM >=150000
190+
staticvoid
191+
mtm_ddl_shmem_request(void)
192+
{
193+
Sizesize=0;
194+
195+
if (prev_shmem_request_hook)
196+
prev_shmem_request_hook();
197+
198+
size=add_size(size,sizeof(structDDLSharedState));
199+
size=add_size(size,hash_estimate_size(MULTIMASTER_MAX_LOCAL_TABLES,
200+
sizeof(Oid)));
201+
size=MAXALIGN(size);
202+
203+
RequestAddinShmemSpace(size);
204+
RequestNamedLWLockTranche("mtm-ddl",1);
205+
}
206+
#endif
207+
186208
void
187209
MtmDDLReplicationShmemStartup(void)
188210
{

‎src/dmq.c‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ static volatile sig_atomic_t got_SIGHUP = false;
240240

241241
staticshmem_startup_hook_typePreviousShmemStartupHook;
242242

243+
#ifPG_VERSION_NUM >=150000
244+
staticshmem_request_hook_typeprev_shmem_request_hook=NULL;
245+
staticvoidmtm_dmq_shmem_request(void);
246+
#endif
247+
243248
void*(*dmq_receiver_start_hook)(char*sender_name);
244249
dmq_hook_typedmq_receiver_stop_hook;
245250
dmq_hook_typedmq_sender_connect_hook;
@@ -364,14 +369,19 @@ static Size
364369
dmq_shmem_size(void)
365370
{
366371
Sizesize=0;
367-
intmaxbackends=0;
368-
369-
maxbackends=MaxConnections+autovacuum_max_workers+
370-
max_worker_processes+max_wal_senders+1;
372+
#ifPG_VERSION_NUM<150000
373+
intmaxbackends=MaxConnections+autovacuum_max_workers+
374+
max_worker_processes+max_wal_senders+1;
375+
#endif
371376

372377
size=add_size(size,sizeof(structDmqSharedState));
378+
#ifPG_VERSION_NUM >=150000
379+
size=add_size(size,hash_estimate_size(DMQ_MAX_SUBS_PER_BACKEND*MaxBackends,
380+
sizeof(DmqStreamSubscription)));
381+
#else
373382
size=add_size(size,hash_estimate_size(DMQ_MAX_SUBS_PER_BACKEND*maxbackends,
374383
sizeof(DmqStreamSubscription)));
384+
#endif
375385
returnMAXALIGN(size);
376386
}
377387

@@ -384,9 +394,14 @@ dmq_init(int send_timeout, int connect_timeout)
384394
return;
385395

386396
/* Reserve area for our shared state */
397+
#ifPG_VERSION_NUM >=150000
398+
prev_shmem_request_hook=shmem_request_hook;
399+
shmem_request_hook=mtm_dmq_shmem_request;
400+
#else
387401
RequestAddinShmemSpace(dmq_shmem_size());
388402

389403
RequestNamedLWLockTranche("dmq",1);
404+
#endif
390405

391406
/* Set up common data for all our workers */
392407
memset(&worker,0,sizeof(worker));
@@ -408,6 +423,18 @@ dmq_init(int send_timeout, int connect_timeout)
408423
shmem_startup_hook=dmq_shmem_startup_hook;
409424
}
410425

426+
#ifPG_VERSION_NUM >=150000
427+
staticvoid
428+
mtm_dmq_shmem_request(void)
429+
{
430+
if (prev_shmem_request_hook)
431+
prev_shmem_request_hook();
432+
433+
RequestAddinShmemSpace(dmq_shmem_size());
434+
RequestNamedLWLockTranche("dmq",1);
435+
}
436+
#endif
437+
411438
staticSize
412439
dmq_toc_size()
413440
{

‎src/global_tx.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ char const *const GlobalTxStatusMnem[] =
4747
"GTXAborted"
4848
};
4949

50+
#ifPG_VERSION_NUM >=150000
51+
staticshmem_request_hook_typeprev_shmem_request_hook=NULL;
52+
staticvoidmtm_gtx_shmem_request(void);
53+
#endif
54+
5055
int
5156
term_cmp(GlobalTxTermt1,GlobalTxTermt2)
5257
{
@@ -153,9 +158,25 @@ GlobalTxAtExit(int code, Datum arg)
153158

154159
void
155160
MtmGlobalTxInit()
161+
{
162+
#ifPG_VERSION_NUM >=150000
163+
prev_shmem_request_hook=shmem_request_hook;
164+
shmem_request_hook=mtm_gtx_shmem_request;
165+
#else
166+
RequestAddinShmemSpace(size);
167+
RequestNamedLWLockTranche("mtm-gtx-lock",1);
168+
#endif
169+
}
170+
171+
#ifPG_VERSION_NUM >=150000
172+
staticvoid
173+
mtm_gtx_shmem_request(void)
156174
{
157175
Sizesize=0;
158176

177+
if (prev_shmem_request_hook)
178+
prev_shmem_request_hook();
179+
159180
size=add_size(size,sizeof(gtx_shared_data));
160181
size=add_size(size,hash_estimate_size(2*MaxConnections,
161182
sizeof(GlobalTx)));
@@ -164,6 +185,7 @@ MtmGlobalTxInit()
164185
RequestAddinShmemSpace(size);
165186
RequestNamedLWLockTranche("mtm-gtx-lock",1);
166187
}
188+
#endif
167189

168190
void
169191
MtmGlobalTxShmemStartup(void)

‎src/multimaster.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ bool mtm_config_valid;
220220

221221
staticshmem_startup_hook_typePreviousShmemStartupHook;
222222

223+
#ifPG_VERSION_NUM >=150000
224+
staticshmem_request_hook_typeprev_shmem_request_hook=NULL;
225+
staticvoidmtm_shmem_request(void);
226+
#endif
223227

224228
/*
225229
* If you get really bored one day, you may try hardware-accelerated popcount
@@ -716,8 +720,13 @@ NULL);
716720
* the postmaster process.) We'll allocate or attach to the shared
717721
* resources in mtm_shmem_startup().
718722
*/
723+
#ifPG_VERSION_NUM >=150000
724+
prev_shmem_request_hook=shmem_request_hook;
725+
shmem_request_hook=mtm_shmem_request;
726+
#else
719727
RequestAddinShmemSpace(MTM_SHMEM_SIZE+sizeof(MtmTime));
720728
RequestNamedLWLockTranche(MULTIMASTER_NAME,2);
729+
#endif
721730

722731
dmq_init(MtmHeartbeatSendTimeout,MtmConnectTimeout);
723732
dmq_receiver_start_hook=MtmOnDmqReceiverConnect;
@@ -750,6 +759,18 @@ NULL);
750759
#endif
751760
}
752761

762+
#ifPG_VERSION_NUM >=150000
763+
staticvoid
764+
mtm_shmem_request(void)
765+
{
766+
if (prev_shmem_request_hook)
767+
prev_shmem_request_hook();
768+
769+
RequestAddinShmemSpace(MTM_SHMEM_SIZE+sizeof(MtmTime));
770+
RequestNamedLWLockTranche(MULTIMASTER_NAME,2);
771+
}
772+
#endif
773+
753774
/*
754775
* Module unload callback
755776
*

‎src/state.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ static PrepareBarrierMode pb_acquired_in_mode;
246246

247247
staticboolcampaign_requested;
248248

249+
#ifPG_VERSION_NUM >=150000
250+
staticshmem_request_hook_typeprev_shmem_request_hook=NULL;
251+
staticvoidmtm_state_shmem_request(void);
252+
#endif
253+
249254
/*
250255
* -----------------------------------
251256
* Startup
@@ -255,10 +260,27 @@ static boolcampaign_requested;
255260
void
256261
MtmStateInit()
257262
{
263+
#ifPG_VERSION_NUM >=150000
264+
prev_shmem_request_hook=shmem_request_hook;
265+
shmem_request_hook=mtm_state_shmem_request;
266+
#else
258267
RequestAddinShmemSpace(sizeof(structMtmState));
259268
RequestNamedLWLockTranche("mtm_state_locks",3);
269+
#endif
260270
}
261271

272+
#ifPG_VERSION_NUM >=150000
273+
staticvoid
274+
mtm_state_shmem_request(void)
275+
{
276+
if (prev_shmem_request_hook)
277+
prev_shmem_request_hook();
278+
279+
RequestAddinShmemSpace(sizeof(structMtmState));
280+
RequestNamedLWLockTranche("mtm_state_locks",3);
281+
}
282+
#endif
283+
262284
void
263285
MtmStateShmemStartup()
264286
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp