Skip to content

Commit 480cda0

Browse files
committed
Add bgwpool
1 parent c19018d commit 480cda0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

contrib/multimaster/multimaster.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ static void DtmInitialize()
716716
dtm->nNodes = MMNodes;
717717
pg_atomic_write_u32(&dtm->nReceivers, 0);
718718
dtm->initialized = false;
719+
dtm->pool = BgwPoolCreate(MMExecutor, MMDatabaseName, MMQueueSize, MMWorkers);
719720
RegisterXactCallback(DtmXactCallback, NULL);
720721
}
721722
LWLockRelease(AddinShmemInitLock);
@@ -824,14 +825,6 @@ _PG_init(void)
824825
if (!process_shared_preload_libraries_in_progress)
825826
return;
826827

827-
/*
828-
* Request additional shared resources. (These are no-ops if we're not in
829-
* the postmaster process.) We'll allocate or attach to the shared
830-
* resources in imcs_shmem_startup().
831-
*/
832-
RequestAddinShmemSpace(DTM_SHMEM_SIZE);
833-
RequestAddinLWLocks(2);
834-
835828
DefineCustomIntVariable(
836829
"multimaster.workers",
837830
"Number of multimaster executor workers per node",
@@ -948,11 +941,18 @@ _PG_init(void)
948941
NULL
949942
);
950943

944+
/*
945+
* Request additional shared resources. (These are no-ops if we're not in
946+
* the postmaster process.) We'll allocate or attach to the shared
947+
* resources in dtm_shmem_startup().
948+
*/
949+
RequestAddinShmemSpace(DTM_SHMEM_SIZE + MMQueueSize);
950+
RequestAddinLWLocks(2);
951+
951952
MMNodes = MMStartReceivers(MMConnStrs, MMNodeId);
952953
if (MMNodes < 2) {
953954
elog(ERROR, "Multimaster should have at least two nodes");
954955
}
955-
dtm->pool = BgwPoolCreate(MMExecutor, MMDatabaseName, MMQueueSize, MMWorkers);
956956

957957
if (DtmBufferSize != 0)
958958
{
@@ -1189,6 +1189,7 @@ static void MMExecutor(int id, void* work, size_t size)
11891189
TransactionId xid = *(TransactionId*)work;
11901190
char* stmts = (char*)work + 4;
11911191
int rc = SPI_ERROR_TRANSACTION;
1192+
11921193
MMJoinTransaction(xid);
11931194

11941195
SetCurrentStatementStartTimestamp();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy