Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 464df6d

Browse files
committed
clean up headers
1 parent aad8e95 commit 464df6d

13 files changed

+235
-252
lines changed

src/bgwpool.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "tcop/tcopprot.h"
1616

1717
#include "bgwpool.h"
18-
#include "mm.h"
18+
#include "multimaster.h"
1919
#include "logger.h"
2020

2121
bool MtmIsPoolWorker;
@@ -145,7 +145,7 @@ void BgwPoolInit(BgwPool* pool, BgwPoolExecutor executor, char const* dbname, c
145145
pool->bgwhandles = (BackgroundWorkerHandle **) ShmemAlloc(MtmMaxWorkers * sizeof(BackgroundWorkerHandle *));
146146
pool->queue = (char*)ShmemAlloc(queueSize);
147147
if (pool->queue == NULL) {
148-
elog(PANIC, "Failed to allocate memory for background workers pool: %lld bytes requested", (long64)queueSize);
148+
elog(PANIC, "Failed to allocate memory for background workers pool: %zd bytes requested", queueSize);
149149
}
150150
pool->executor = executor;
151151
pool->available = PGSemaphoreCreate();

src/bkb.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include <stdint.h>
22
#include "bkb.h"
33

4+
#define BIT_CHECK(mask, bit) (((mask) & ((nodemask_t)1 << (bit))) != 0)
5+
#define BIT_SET(mask, bit) (mask |= ((nodemask_t)1 << (bit)))
6+
47
/*
58
* Bron–Kerbosch algorithm to find maximum clique in graph
6-
*/
9+
*/
710

811
typedef struct {
912
int size;

src/ddd.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ MtmDetectGlobalDeadLockForXid(TransactionId xid)
402402
}
403403
MtmGetGtid(xid, &gtid);
404404
hasDeadlock = MtmGraphFindLoop(&graph, &gtid);
405-
mtm_log(DeadlockCheck, "Distributed deadlock check by backend %d for %u:%llu = %d",
406-
MyProcPid, gtid.node, (long64)gtid.xid, hasDeadlock);
405+
mtm_log(DeadlockCheck, "Distributed deadlock check by backend %d for %u:" XID_FMT " = %d",
406+
MyProcPid, gtid.node, gtid.xid, hasDeadlock);
407407
// if (!hasDeadlock) {
408408
// /* There is no deadlock loop in graph, but deadlock can be caused by lack of apply workers: if all of them are busy, then some transactions
409409
// * can not be appied just because there are no vacant workers and it cause additional dependency between transactions which is not
@@ -423,8 +423,8 @@ MtmDetectGlobalDeadLockForXid(TransactionId xid)
423423
if (!hasDeadlock)
424424
{
425425
// TimestampTz start_time = get_timeout_start_time(DEADLOCK_TIMEOUT);
426-
mtm_log(DeadlockCheck, "Enable deadlock timeout in backend %d for transaction %llu",
427-
MyProcPid, (long64)xid);
426+
mtm_log(DeadlockCheck, "Enable deadlock timeout in backend %d for transaction " XID_FMT,
427+
MyProcPid, xid);
428428
enable_timeout_after(DEADLOCK_TIMEOUT, DeadlockTimeout);
429429
// set_timeout_start_time(DEADLOCK_TIMEOUT, start_time);
430430
}
@@ -437,7 +437,7 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
437437
{
438438
PGXACT* pgxact = &ProcGlobal->allPgXact[proc->pgprocno];
439439

440-
mtm_log(DeadlockCheck, "Detect global deadlock for %llu by backend %d", (long64)pgxact->xid, MyProcPid);
440+
mtm_log(DeadlockCheck, "Detect global deadlock for " XID_FMT " by backend %d", pgxact->xid, MyProcPid);
441441

442442
if (Mtm->status != MTM_ONLINE || !TransactionIdIsValid(pgxact->xid))
443443
return false;
@@ -468,10 +468,10 @@ mtm_dump_lock_graph(PG_FUNCTION_ARGS)
468468
appendStringInfo(s, "node-%d lock graph: ", i+1);
469469
while (gtid != last) {
470470
GlobalTransactionId *src = gtid++;
471-
appendStringInfo(s, "%d:%llu -> ", src->node, (long64)src->xid);
471+
appendStringInfo(s, "%d:"XID_FMT" -> ", src->node, src->xid);
472472
while (gtid->node != 0) {
473473
GlobalTransactionId *dst = gtid++;
474-
appendStringInfo(s, "%d:%llu, ", dst->node, (long64)dst->xid);
474+
appendStringInfo(s, "%d:"XID_FMT", ", dst->node, dst->xid);
475475
}
476476
gtid += 1;
477477
}

src/include/bgwpool.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
#include "storage/pg_sema.h"
77
#include "postmaster/bgworker.h"
88
#include "storage/condition_variable.h"
9-
#include "bkb.h" // XXX
109

11-
#include "mm.h"
10+
#include "receiver.h"
1211

1312
typedef void(*BgwPoolExecutor)(void* work, size_t size, MtmReceiverContext *ctx);
1413

@@ -23,8 +22,6 @@ typedef long timestamp_t;
2322
extern timestamp_t MtmGetSystemTime(void); /* non-adjusted current system time */
2423
extern timestamp_t MtmGetCurrentTime(void); /* adjusted current system time */
2524

26-
extern int MtmMaxWorkers;
27-
2825
typedef struct
2926
{
3027
BgwPoolExecutor executor;

src/include/bkb.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
#ifndef __BKB_H__
55
#define __BKB_H__
66

7-
#include "mm.h"
7+
#include "postgres.h" /* nodemask_t */
8+
9+
#define MAX_NODES sizeof(nodemask_t)
10+
typedef uint64 nodemask_t;
811

912
extern nodemask_t MtmFindMaxClique(nodemask_t* matrix, int n_modes, int* clique_size);
1013

src/include/ddl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "utils/relcache.h"
1616

17+
/* GUCs */
1718
extern bool MtmMonotonicSequences;
1819
extern char *MtmRemoteFunctionsList;
1920
extern bool MtmVolksWagenMode;

src/include/mm.h

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,8 @@
1-
/*-------------------------------------------------------------------------
2-
*
3-
* mm.h
4-
* General definitions
5-
*
6-
*
7-
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
8-
* Portions Copyright (c) 1994, Regents of the University of California
9-
*
10-
*-------------------------------------------------------------------------
11-
*/
1+
122
#ifndef MM_H
133
#define MM_H
144

15-
#include "postgres.h"
16-
17-
#include "access/xact.h"
18-
19-
#define MULTIMASTER_SCHEMA_NAME "mtm"
20-
#define MULTIMASTER_LOCAL_TABLES_TABLE "local_tables"
21-
22-
#define MAX_NODES 64
23-
24-
typedef char pgid_t[GIDSIZE];
25-
26-
/* Identifier of global transaction */
27-
typedef struct
28-
{
29-
int node; /* One based id of node initiating transaction */
30-
TransactionId xid; /* Transaction ID at this node */
31-
} GlobalTransactionId;
32-
33-
typedef struct {
34-
TransactionId xid; /* local transaction ID */
35-
bool isTwoPhase; /* user level 2PC */
36-
bool isDistributed; /* transaction performed INSERT/UPDATE/DELETE and has to be replicated to other nodes */
37-
bool containsDML; /* transaction contains DML statements */
38-
pgid_t gid; /* global transaction identifier (used by 2pc) */
39-
} MtmCurrentTrans;
40-
41-
42-
typedef struct MtmSeqPosition
43-
{
44-
Oid seqid;
45-
int64 next;
46-
} MtmSeqPosition;
47-
48-
typedef struct
49-
{
50-
int node_id;
51-
bool is_recovery;
52-
bool parallel_allowed;
53-
TimestampTz session_id;
54-
// XXX
55-
XLogRecPtr end_lsn;
56-
} MtmReceiverContext;
57-
58-
/* XXX: drop that */
59-
typedef long long long64; /* we are not using int64 here because we want to use %lld format for this type */
60-
typedef unsigned long long ulong64; /* we are not using uint64 here because we want to use %lld format for this type */
61-
62-
typedef ulong64 nodemask_t;
63-
64-
65-
#define BIT_CHECK(mask, bit) (((mask) & ((nodemask_t)1 << (bit))) != 0)
66-
#define BIT_CLEAR(mask, bit) (mask &= ~((nodemask_t)1 << (bit)))
67-
#define BIT_SET(mask, bit) (mask |= ((nodemask_t)1 << (bit)))
68-
#define ALL_BITS ((nodemask_t)~0)
69-
70-
extern bool MtmIsLogicalReceiver;
71-
extern bool MtmIsReceiver;
72-
extern bool MtmIsPoolWorker;
73-
74-
extern bool MtmBackgroundWorker;
75-
extern int MtmMaxNodes;
76-
extern int MtmNodeId;
77-
extern MtmCurrentTrans MtmTx;
78-
extern MemoryContext MtmApplyContext;
79-
extern char *MtmDatabaseUser;
80-
815

82-
extern bool MtmTwoPhaseCommit(MtmCurrentTrans* x);
836

847

858

0 commit comments

Comments
 (0)