summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoichi Suzuki2012-12-24 04:23:00 +0000
committerKoichi Suzuki2012-12-24 04:23:00 +0000
commit97d68e6aed0e462c7e1f841c795d583b4c6e12cb (patch)
treeb03fd8c48e1db24c3d03e0c10d27e78d74a93c48
parent71cac949e1847e479a0d6fff1361f7a5b05e6950 (diff)
This commit fixes the bug 3598030, incorrect transaction handling
for direct connection to datanodes. modified: src/backend/access/transam/gtm.c modified: src/backend/access/transam/xact.c modified: src/include/access/gtm.h
-rw-r--r--src/backend/access/transam/gtm.c10
-rw-r--r--src/backend/access/transam/xact.c7
-rw-r--r--src/include/access/gtm.h2
3 files changed, 19 insertions, 0 deletions
diff --git a/src/backend/access/transam/gtm.c b/src/backend/access/transam/gtm.c
index c15e0425b1..b425ce434d 100644
--- a/src/backend/access/transam/gtm.c
+++ b/src/backend/access/transam/gtm.c
@@ -26,6 +26,9 @@ extern bool FirstSnapshotSet;
static GTM_Conn *conn;
+/* Used to check if needed to commit/abort at datanodes */
+GlobalTransactionId currentGxid = InvalidGlobalTransactionId;
+
bool
IsGTMConnected()
{
@@ -133,6 +136,7 @@ BeginTranGTM(GTM_Timestamp *timestamp)
if (conn)
xid = begin_transaction(conn, GTM_ISOLATION_RC, timestamp);
}
+ currentGxid = xid;
return xid;
}
@@ -157,6 +161,7 @@ BeginTranAutovacuumGTM(void)
if (conn)
xid = begin_transaction_autovacuum(conn, GTM_ISOLATION_RC);
}
+ currentGxid = xid;
return xid;
}
@@ -185,6 +190,7 @@ CommitTranGTM(GlobalTransactionId gxid)
if (IsAutoVacuumWorkerProcess() || IsAutoVacuumLauncherProcess())
CloseGTM();
+ currentGxid = InvalidGlobalTransactionId;
return ret;
}
@@ -213,6 +219,7 @@ CommitPreparedTranGTM(GlobalTransactionId gxid, GlobalTransactionId prepared_gxi
CloseGTM();
InitGTM();
}
+ currentGxid = InvalidGlobalTransactionId;
return ret;
}
@@ -238,6 +245,8 @@ RollbackTranGTM(GlobalTransactionId gxid)
CloseGTM();
InitGTM();
}
+
+ currentGxid = InvalidGlobalTransactionId;
return ret;
}
@@ -288,6 +297,7 @@ PrepareTranGTM(GlobalTransactionId gxid)
CloseGTM();
InitGTM();
}
+ currentGxid = InvalidGlobalTransactionId;
return ret;
}
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 27c641c1f1..f826014c10 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -2515,6 +2515,13 @@ AtEOXact_GlobalTxn(bool commit)
else
RollbackTranGTM(s->topGlobalTransansactionId);
}
+ else if (GlobalTransactionIdIsValid(currentGxid))
+ {
+ if (commit)
+ CommitTranGTM(currentGxid);
+ else
+ RollbackTranGTM(currentGxid);
+ }
}
s->topGlobalTransansactionId = InvalidGlobalTransactionId;
diff --git a/src/include/access/gtm.h b/src/include/access/gtm.h
index e7ad25b2cd..5c5692b2c5 100644
--- a/src/include/access/gtm.h
+++ b/src/include/access/gtm.h
@@ -16,6 +16,8 @@
extern char *GtmHost;
extern int GtmPort;
+extern GlobalTransactionId currentGxid;
+
extern bool IsGTMConnected(void);
extern void InitGTM(void);
extern void CloseGTM(void);