Skip to content

Commit 575566e

Browse files
committed
Fix definitions of SQL functions
1 parent 87cd559 commit 575566e

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

contrib/mmts/bgwpool.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ size_t BgwPoolGetQueueSize(BgwPool* pool)
109109

110110
void BgwPoolExecute(BgwPool* pool, void* work, size_t size)
111111
{
112-
Assert(size+4 <= pool->size);
112+
if (size+4 > pool->size) {
113+
/*
114+
* Size of work is larger than size of shared buffer:
115+
* run it immediately
116+
*/
117+
pool->executor(0, work, size);
118+
return;
119+
}
113120

114121
SpinLockAcquire(&pool->lock);
115122
while (true) {

contrib/mmts/multimaster--1.0.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ AS 'MODULE_PATHNAME','mtm_get_snapshot'
2424
LANGUAGE C;
2525

2626

27-
CREATE TYPE mtm.node_state(id integer, disabled bool, disconnected bool, catchUp boolean, slotLag bigint, connStr text);
27+
CREATE TYPE mtm.node_state AS (id integer, disabled bool, disconnected bool, catchUp bool, slotLag bigint, connStr text);
2828

2929
CREATE FUNCTION mtm.get_nodes_state() RETURNS SETOF mtm.node_state
3030
AS 'MODULE_PATHNAME','mtm_get_nodes_state'
3131
LANGUAGE C;
3232

33-
CREATE TYPE mtm.cluster_state(status text, disabledNodeMask bigint, disconnectedNodeMask bigint, catchUpNodeMask bigint, nNodes integer, nActiveQueries integer, queueSize bigint);
33+
CREATE TYPE mtm.cluster_state AS (status text, disabledNodeMask bigint, disconnectedNodeMask bigint, catchUpNodeMask bigint, nNodes integer, nActiveQueries integer, queueSize bigint);
3434

3535
CREATE FUNCTION mtm.get_cluster_state() RETURNS mtm.cluster_state
3636
AS 'MODULE_PATHNAME','mtm_get_cluster_state'

contrib/mmts/multimaster.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ MtmBeginTransaction(MtmCurrentTrans* x)
523523
if (x->isDistributed && dtm->status != MTM_ONLINE) {
524524
/* reject all user's transactions at offline cluster */
525525
MtmUnlock();
526-
elog(ERROR, "Multimaster node is not online");
526+
elog(ERROR, "Multimaster node is not online: current status %s", MtmNodeStatusMnem[dtm->status]);
527527
}
528528
x->containsDML = false;
529529
x->isPrepared = false;
@@ -1159,7 +1159,7 @@ void MtmReceiverStarted(int nodeId)
11591159
BIT_SET(dtm->pglogicalNodeMask, nodeId-1);
11601160
if (++dtm->nReceivers == dtm->nNodes-1) {
11611161
Assert(dtm->status == MTM_CONNECTED);
1162-
MtmSwitchClusterMode(MTM_OFFLINE);
1162+
MtmSwitchClusterMode(MTM_ONLINE);
11631163
}
11641164
}
11651165
SpinLockRelease(&dtm->spinlock);
@@ -1293,6 +1293,7 @@ mtm_get_nodes_state(PG_FUNCTION_ARGS)
12931293
MtmGetNodeStateCtx* usrfctx;
12941294
MemoryContext oldcontext;
12951295
char* p;
1296+
int64 lag;
12961297
bool is_first_call = SRF_IS_FIRSTCALL();
12971298

12981299
if (is_first_call) {
@@ -1315,7 +1316,9 @@ mtm_get_nodes_state(PG_FUNCTION_ARGS)
13151316
usrfctx->values[1] = BoolGetDatum(BIT_CHECK(dtm->disabledNodeMask, usrfctx->nodeId-1));
13161317
usrfctx->values[2] = BoolGetDatum(BIT_CHECK(dtm->connectivityMask, usrfctx->nodeId-1));
13171318
usrfctx->values[3] = BoolGetDatum(BIT_CHECK(dtm->nodeLockerMask, usrfctx->nodeId-1));
1318-
usrfctx->values[4] = Int64GetDatum(MtmGetSlotLag(usrfctx->nodeId));
1319+
lag = MtmGetSlotLag(usrfctx->nodeId);
1320+
usrfctx->values[4] = Int64GetDatum(lag);
1321+
usrfctx->nulls[4] = lag < 0;
13191322
p = strchr(usrfctx->connStrPtr, ',');
13201323
if (p != NULL) {
13211324
*p++ = '\0';
@@ -1333,7 +1336,6 @@ mtm_get_cluster_state(PG_FUNCTION_ARGS)
13331336
TupleDesc desc;
13341337
Datum values[7];
13351338
bool nulls[7] = {false};
1336-
13371339
get_call_result_type(fcinfo, NULL, &desc);
13381340

13391341
values[0] = CStringGetTextDatum(MtmNodeStatusMnem[dtm->status]);

contrib/mmts/pglogical_receiver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ pglogical_receiver_main(Datum main_arg)
331331
if (rc & WL_POSTMASTER_DEATH)
332332
proc_exit(1);
333333

334-
if (ds->status != MTM_ONLINE && (ds->status != MTM_RECOVERY || ds->recoverySlot != args->remote_node)) {
335-
ereport(LOG, (errmsg("%s: terminating WAL receiver because node is switched to %s mode", worker_proc, MtmNodeStatusMnem[ds->status])));
334+
if (ds->status == MTM_OFFLINE || (ds->status == MTM_RECOVERY && ds->recoverySlot != args->remote_node)) {
335+
ereport(LOG, (errmsg("%s: terminating WAL receiver because node was switched to %s mode", worker_proc, MtmNodeStatusMnem[ds->status])));
336336
proc_exit(0);
337337
}
338338

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