* Report BARRIER
*/
int
-ReportBarrierGTM(char *barrier_id)
+ReportBarrierGTM(const char *barrier_id)
{
if (!gtm_backup_barrier)
return EINVAL;
#include "utils/snapmgr.h"
#ifdef PGXC
+#include "storage/procarray.h"
#include "utils/builtins.h"
#endif
* durably commit.
*/
#ifdef XCP
+ latestXid = InvalidTransactionId;
if (!IsConnFromDatanode())
#endif
latestXid = RecordTransactionCommit();
#include "nodes/makefuncs.h"
#include "pg_getopt.h"
#include "postmaster/bgwriter.h"
+#include "postmaster/clustermon.h"
#include "postmaster/startup.h"
#include "postmaster/walwriter.h"
#include "replication/walreceiver.h"
/* If no quals, no equijoin */
if (!quals)
- return false;
+ return NULL;
/*
* Make a copy of the argument bitmaps, it will be modified by
* bms_first_member().
for (;;)
{
Datum value = (Datum) 0;
- bool isnull;
+ bool isnull = false;
int numnodes;
int i;
GlobalTransactionId gxid, prepare_gxid;
bool prepared_local = false;
+ /*
+ * Get the list of nodes involved in this transaction.
+ *
+ * This function returns the GXID of the prepared transaction. It also
+ * returns a fresh GXID which can be used for running COMMIT PREPARED
+ * commands on the remote nodes. Both these GXIDs can then be either
+ * committed or aborted together.
+ *
+ * XXX While I understand that we get the prepared and a new GXID with a
+ * single call, it doesn't look nicer and create confusion. We should
+ * probably split them into two parts. This is used only for explicit 2PC
+ * which should not be very common in XC
+ */
+ if (GetGIDDataGTM(prepareGID, &gxid, &prepare_gxid, &nodestring) < 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_INTERNAL_ERROR),
+ errmsg("prepared transaction with identifier \"%s\" does not exist",
+ prepareGID)));
+
/*
* Please note that with xc_maintenance_mode = on, COMMIT/ROLLBACK PREPARED will not
* propagate to remote nodes. Only GTM status is cleaned up.
return false;
}
- /*
- * Get the list of nodes involved in this transaction.
- *
- * This function returns the GXID of the prepared transaction. It also
- * returns a fresh GXID which can be used for running COMMIT PREPARED
- * commands on the remote nodes. Both these GXIDs can then be either
- * committed or aborted together.
- *
- * XXX While I understand that we get the prepared and a new GXID with a
- * single call, it doesn't look nicer and create confusion. We should
- * probably split them into two parts. This is used only for explicit 2PC
- * which should not be very common in XC
- */
- if (GetGIDDataGTM(prepareGID, &gxid, &prepare_gxid, &nodestring) < 0)
- ereport(ERROR,
- (errcode(ERRCODE_INTERNAL_ERROR),
- errmsg("prepared transaction with identifier \"%s\" does not exist",
- prepareGID)));
prepared_local = pgxc_node_remote_finish(prepareGID, commit, nodestring,
gxid, prepare_gxid);
if (poll_val == 0)
{
/* Handle timeout */
- elog(DEBUG1, "timeout %d while waiting for any response from %d connections", timeout_ms,conn_count);
+ elog(DEBUG1, "timeout %ld while waiting for any response from %d connections", timeout_ms,conn_count);
for (i = 0; i < conn_count; i++)
connections[i]->state = DN_CONNECTION_STATE_ERROR_FATAL;
return NO_ERROR_OCCURED;
{
volatile SQueueSync *sqsync = sq->sq_sync;
int i;
- char ntype = PGXC_NODE_DATANODE;
Assert(sqsync && sqsync->queue == sq);
#include <sys/time.h>
#include <unistd.h>
+#include "access/gtm.h"
#include "access/transam.h"
#include "access/xact.h"
#include "gtm/gtm_c.h"
#include "postmaster/clustermon.h"
#include "postmaster/fork_process.h"
#include "postmaster/postmaster.h"
+#include "storage/ipc.h"
#include "storage/proc.h"
+#include "storage/procarray.h"
#include "storage/spin.h"
#include "tcop/tcopprot.h"
#include "utils/memutils.h"
/* Flags set by signal handlers */
static volatile sig_atomic_t got_SIGHUP = false;
-static volatile sig_atomic_t got_SIGUSR2 = false;
static volatile sig_atomic_t got_SIGTERM = false;
/* Memory context for long-lived data */
static void cm_sighup_handler(SIGNAL_ARGS);
static void cm_sigterm_handler(SIGNAL_ARGS);
static void ClusterMonitorSetReportedGlobalXmin(GlobalTransactionId xmin);
-static GlobalTransactionId ClusterMonitorGetReportedGlobalXmin(void);
static void ClusterMonitorSetReportingGlobalXmin(GlobalTransactionId xmin);
/* PID of clustser monitoring process */
{
elog(DEBUG1, "Failed (status %d) to report RecentGlobalXmin "
"- reported RecentGlobalXmin %d, received "
- "RecentGlobalXmin %d, " "received latestCompletedXid",
+ "RecentGlobalXmin %d, " "received latestCompletedXid %d",
status, oldestXmin, newOldestXmin,
latestCompletedXid);
if (status == GTM_ERRCODE_TOO_OLD_XMIN ||
SpinLockRelease(&ClusterMonitorCtl->mutex);
}
-static GlobalTransactionId
-ClusterMonitorGetReportedGlobalXmin(void)
-{
- GlobalTransactionId reported_xmin;
-
- SpinLockAcquire(&ClusterMonitorCtl->mutex);
- reported_xmin = ClusterMonitorCtl->reported_recent_global_xmin;
- SpinLockRelease(&ClusterMonitorCtl->mutex);
-
- return reported_xmin;
-}
-
static void
ClusterMonitorSetReportingGlobalXmin(GlobalTransactionId xmin)
{
#include "pgxc/nodemgr.h"
#endif
#include "postmaster/autovacuum.h"
+#include "postmaster/clustermon.h"
#include "postmaster/bgworker_internals.h"
#include "postmaster/bgwriter.h"
#include "postmaster/postmaster.h"
void
SetLatestCompletedXid(TransactionId latestCompletedXid)
{
- int index;
- ProcArrayStruct *arrayP = procArray;
-
if (!TransactionIdIsValid(latestCompletedXid))
return;
/*
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
-
-#ifndef HAVE_GETRUSAGE
-#include "rusagestub.h"
-#endif
#include "access/parallel.h"
#include "access/printtup.h"
#include "pgxc/pgxc.h"
#endif
#include "postmaster/autovacuum.h"
+#include "postmaster/clustermon.h"
#include "postmaster/postmaster.h"
#include "replication/walsender.h"
#include "storage/bufmgr.h"
int
bkup_begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
bool read_only,
- char *global_sessionid,
+ const char *global_sessionid,
uint32 client_id, GTM_Timestamp timestamp)
{
uint32 global_sessionid_len = global_sessionid ?
int
bkup_begin_transaction_gxid(GTM_Conn *conn, GlobalTransactionId gxid,
GTM_IsolationLevel isolevel, bool read_only,
- char *global_sessionid,
+ const char *global_sessionid,
uint32 client_id, GTM_Timestamp timestamp)
{
uint32 global_sessionid_len = global_sessionid ?
GlobalTransactionId
begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
- char *global_sessionid,
+ const char *global_sessionid,
GTM_Timestamp *timestamp)
{
bool txn_read_only = false;
bkup_begin_transaction_multi(GTM_Conn *conn, int txn_count,
GlobalTransactionId *gxid, GTM_IsolationLevel *isolevel,
bool *read_only,
- char *txn_global_sessionid[],
+ const char *txn_global_sessionid[],
uint32 *client_id,
GTMProxy_ConnID *txn_connid)
{
#include <unistd.h>
#include <stdlib.h>
+#include "postgres.h"
#include "mb/pg_wchar.h"
#include "gtm/path.h"
#include "gtm/assert.h"
GTM_IsolationLevel txn_isolation_level[GTM_MAX_GLOBAL_TRANSACTIONS];
bool txn_read_only[GTM_MAX_GLOBAL_TRANSACTIONS];
uint32 txn_global_sessionid_len;
- char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
+ const char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
int txn_count, new_txn_count;
StringInfoData buf;
GTM_TransactionHandle txn[GTM_MAX_GLOBAL_TRANSACTIONS];
GTM_IsolationLevel txn_isolation_level[GTM_MAX_GLOBAL_TRANSACTIONS];
bool txn_read_only[GTM_MAX_GLOBAL_TRANSACTIONS];
uint32 txn_global_sessionid_len;
- char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
+ const char *txn_global_sessionid[GTM_MAX_GLOBAL_TRANSACTIONS];
GTMProxy_ConnID txn_connid[GTM_MAX_GLOBAL_TRANSACTIONS];
uint32 txn_client_id[GTM_MAX_GLOBAL_TRANSACTIONS];
int ii;
MemoryContext oldContext;
int status = STATUS_OK;
int waited_xid_count;
- GlobalTransactionId *waited_xids;
+ GlobalTransactionId *waited_xids = NULL;
const char *data = pq_getmsgbytes(message, sizeof (gxid));
waited_xid_count = pq_getmsgint(message, sizeof (int));
if (waited_xid_count > 0)
{
- waited_xids = pq_getmsgbytes(message,
+ waited_xids = (GlobalTransactionId *) pq_getmsgbytes(message,
waited_xid_count * sizeof (GlobalTransactionId));
}
int status[txn_count];
int ii;
int waited_xid_count;
- GlobalTransactionId *waited_xids;
+ GlobalTransactionId *waited_xids = NULL;
for (ii = 0; ii < txn_count; ii++)
{
waited_xid_count = pq_getmsgint(message, sizeof (int));
if (waited_xid_count > 0)
{
- waited_xids = pq_getmsgbytes(message,
+ waited_xids = (GlobalTransactionId *) pq_getmsgbytes(message,
waited_xid_count * sizeof (GlobalTransactionId));
}
extern int DropSequenceGTM(char *name, GTM_SequenceKeyType type);
extern int RenameSequenceGTM(char *seqname, const char *newseqname);
/* Barrier */
-extern int ReportBarrierGTM(char *barrier_id);
+extern int ReportBarrierGTM(const char *barrier_id);
extern int ReportGlobalXmin(GlobalTransactionId gxid,
GlobalTransactionId *global_xmin,
GlobalTransactionId *latest_completed_xid);
* Transaction Management API
*/
GlobalTransactionId begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
- char *global_sessionid,
+ const char *global_sessionid,
GTM_Timestamp *timestamp);
int bkup_begin_transaction(GTM_Conn *conn, GTM_IsolationLevel isolevel,
- bool read_only, char *global_sessionid,
+ bool read_only, const char *global_sessionid,
uint32 client_id, GTM_Timestamp timestamp);
int bkup_begin_transaction_gxid(GTM_Conn *conn, GlobalTransactionId gxid,
GTM_IsolationLevel isolevel, bool read_only,
- char *global_sessionid,
+ const char *global_sessionid,
uint32 client_id, GTM_Timestamp timestamp);
GlobalTransactionId begin_transaction_autovacuum(GTM_Conn *conn, GTM_IsolationLevel isolevel);
bkup_begin_transaction_multi(GTM_Conn *conn, int txn_count,
GlobalTransactionId *gxid, GTM_IsolationLevel *isolevel,
bool *read_only,
- char *txn_global_sessionid[],
+ const char *txn_global_sessionid[],
uint32 *client_id,
GTMProxy_ConnID *txn_connid);
int
GTM_TransactionStates GTM_GetStatusGXID(GlobalTransactionId gxid);
int GTM_GetAllTransactions(GTM_TransactionInfo txninfo[], uint32 txncnt);
void GTM_RemoveAllTransInfos(uint32 client_id, int backend_id);
+uint32 GTMGetFirstClientIdentifier(void);
uint32 GTMGetLastClientIdentifier(void);
GTM_Snapshot GTM_GetSnapshotData(GTM_TransactionInfo *my_txninfo,
#include "utils/elog.h"
#include "utils/palloc.h"
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
+#ifndef HAVE_GETRUSAGE
+#include "rusagestub.h"
+#endif
+
/* ----------------------------------------------------------------
* Section 1: variable-length datatypes (TOAST support)
* ----------------------------------------------------------------
//#define PGXC_COORD // for PGXC coordinator compiling
//#define PGXC_DATANODE // for PGXC data node compiling
+
+extern void ResetUsageCommon(struct rusage *save_r, struct timeval *save_t);
+extern void ResetUsage(void);
+extern void ShowUsageCommon(const char *title, struct rusage *save_r, struct
+ timeval *save_t);
+
#endif /* POSTGRES_H */
#ifndef CLUSTERMON_H
#define CLUSTERMON_H
+#include "gtm/gtm_c.h"
+
typedef struct
{
slock_t mutex;
extern int StartClusterMonitor(void);
GlobalTransactionId ClusterMonitorGetGlobalXmin(void);
void ClusterMonitorSetGlobalXmin(GlobalTransactionId xmin);
-GlobalTransactionId ClusterMonitorGetReportingXmin(void);
+extern GlobalTransactionId ClusterMonitorGetReportingGlobalXmin(void);
+
+Size ClusterMonitorShmemSize(void);
+void ClusterMonitorShmemInit(void);
#ifdef EXEC_BACKEND
extern void ClusterMonitorIAm(void);