Merge pull request #1842 from selvaganesang/commit_nowait
[TRAFODION-3310] Commit transaction needs to be complete before returning to the caller.
diff --git a/core/sqf/src/tm/tminfo.cpp b/core/sqf/src/tm/tminfo.cpp
index 2017893..6947a49 100644
--- a/core/sqf/src/tm/tminfo.cpp
+++ b/core/sqf/src/tm/tminfo.cpp
@@ -106,7 +106,6 @@
iv_SysRecovMode = TM_DEFAULT_SYSRECOVERY_MODE;
iv_maxRecoveringTxns = TM_DEFAULT_MAXRECOVERINGTXNS;
iv_AllRmParticRecov = DEFAULT_ALL_RM_PARTIC_RECOV;
- iv_earlyCommitReply = TM_DEFAULT_EARLY_COMMIT_REPLY;
memset(iv_open_tms, 0, sizeof(Tm_phandle_info) * MAX_NODES);
@@ -830,17 +829,6 @@
trace_printf("TM will use a single TLOG for all audit.\n");
}
- iv_earlyCommitReply = TM_DEFAULT_EARLY_COMMIT_REPLY;
- ms_getenv_bool ("DTM_EARLYCOMMITREPLY", &iv_earlyCommitReply);
-
- if (iv_trace_level)
- {
- if (iv_earlyCommitReply)
- trace_printf("TM will reply early to HBase commits.\n");
- else
- trace_printf("TM will wait for HBase commits to complete before replying.\n");
- }
-
int lv_maxRecoveringTxns = 0;
ms_getenv_int ("DTM_MAXRECOVERINGTXNS", &lv_maxRecoveringTxns);
diff --git a/core/sqf/src/tm/tminfo.h b/core/sqf/src/tm/tminfo.h
index 9a06378..7db8609 100644
--- a/core/sqf/src/tm/tminfo.h
+++ b/core/sqf/src/tm/tminfo.h
@@ -159,7 +159,6 @@
bool iv_allTMsOpen;
int32 iv_sync_otag;
bool iv_TSE_xa_start;
- bool iv_earlyCommitReply;
// Audit and control points
bool iv_write_cp;
bool iv_initiate_cp;
@@ -519,8 +518,6 @@
void tm_up();
void wake_TMUP_waiters(short pv_error);
bool TSE_xa_start() {return iv_TSE_xa_start;}
- bool earlyCommitReply() {return iv_earlyCommitReply;}
- void earlyCommitReply(bool pv_set) {iv_earlyCommitReply=pv_set;}
bool tmTrace(int level) {if (iv_trace_level >= level) return true; return false;}
int32 iv_trace_level;
diff --git a/core/sqf/src/tm/tmtx.cpp b/core/sqf/src/tm/tmtx.cpp
index bba75a2..6bbf325 100644
--- a/core/sqf/src/tm/tmtx.cpp
+++ b/core/sqf/src/tm/tmtx.cpp
@@ -298,12 +298,6 @@
case XA_OK:
{
iv_tx_state = TM_TX_STATE_FORGETTING;
- if (gv_tm_info.earlyCommitReply() && pp_msg->replyPending())
- // For HBase branches we need to reply here if there were no other branches.
- // This is the early reply for commit. However, we still need to wait for the
- // HBase library to complete commit processing before we can forget the transaction.
- pp_msg->reply(FEOK);
- // Now wait for the HBase library to complete it's work.
lv_error = branches()->completeRequest_branches(this);
break;
}
diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp
index 3daae36..b4f16d3 100644
--- a/core/sql/cli/Cli.cpp
+++ b/core/sql/cli/Cli.cpp
@@ -7153,16 +7153,6 @@
}
break;
- case SQLTRANS_BEGIN_WITH_DP2_XNS:
- {
- if (! (currContext.getTransaction()->xnInProgress()))
- {
- currContext.getTransaction()->beginTransaction();
- currContext.getTransaction()->setDp2Xns(TRUE);
- }
- }
- break;
-
case SQLTRANS_SUSPEND:
{
currContext.getTransaction()->suspendTransaction();
@@ -10571,7 +10561,7 @@
cliRC = cqdCliInterface->beginWork();
if (cliRC < 0)
{
- if (myDiags != NULL)
+ if (myDiags == NULL)
myDiags = ComDiagsArea::allocate(exHeap);
cqdCliInterface->retrieveSQLDiagnostics(myDiags);
diags.mergeAfter(*myDiags);
diff --git a/core/sql/cli/Context.cpp b/core/sql/cli/Context.cpp
index 5d4fc71..e004aab 100644
--- a/core/sql/cli/Context.cpp
+++ b/core/sql/cli/Context.cpp
@@ -1117,12 +1117,12 @@
return SUCCESS;
}
-short ContextCli::commitTransaction(NABoolean waited)
+short ContextCli::commitTransaction()
{
releaseAllTransactionalRequests();
// now do the actual commit
- return transaction_->commitTransaction(waited);
+ return transaction_->commitTransaction();
}
short ContextCli::releaseAllTransactionalRequests()
diff --git a/core/sql/cli/Context.h b/core/sql/cli/Context.h
index e18c3d5..fb037dd 100644
--- a/core/sql/cli/Context.h
+++ b/core/sql/cli/Context.h
@@ -665,7 +665,7 @@
void addToOpenStatementList(SQLSTMT_ID *statement_id, Statement *statement);
void removeFromOpenStatementList(SQLSTMT_ID * statement_id);
- short commitTransaction(NABoolean waited);
+ short commitTransaction();
short releaseAllTransactionalRequests();
void closeAllCursors(enum CloseCursorType,
diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp
index 4163292..9c27b3b 100644
--- a/core/sql/cli/Statement.cpp
+++ b/core/sql/cli/Statement.cpp
@@ -4892,10 +4892,7 @@
StmtDebug2(" About to COMMIT, stmt %p, tx %s...", this,
TransIdToText(statementGlobals_->getTransid()));
// do waited commit for DDL queries
- NABoolean waited = FALSE;
- //if (root_tdb->ddlQuery())
- // waited = TRUE;
- short taRetcode = context_->commitTransaction(waited);
+ short taRetcode = context_->commitTransaction();
StmtDebug1(" Return code is %d", (Lng32) taRetcode);
diff --git a/core/sql/cli/sqlcli.h b/core/sql/cli/sqlcli.h
index 656f611..2bed109 100644
--- a/core/sql/cli/sqlcli.h
+++ b/core/sql/cli/sqlcli.h
@@ -702,8 +702,6 @@
to abort any implicit transactions started by cli */
SQLTRANS_ROLLBACK_IMPLICIT_XN = 8,
- SQLTRANS_BEGIN_WITH_DP2_XNS = 9,
-
/* inherit the global transaction and make it the current xn */
SQLTRANS_INHERIT = 10,
diff --git a/core/sql/common/ComTransInfo.h b/core/sql/common/ComTransInfo.h
index 36af463..28813f9 100644
--- a/core/sql/common/ComTransInfo.h
+++ b/core/sql/common/ComTransInfo.h
@@ -47,7 +47,7 @@
enum TransStmtType
{
- BEGIN_, COMMIT_, COMMIT_WAITED_, ROLLBACK_, ROLLBACK_WAITED_,
+ BEGIN_, COMMIT_, ROLLBACK_, ROLLBACK_WAITED_,
SET_TRANSACTION_
};
diff --git a/core/sql/executor/ExExeUtilCli.cpp b/core/sql/executor/ExExeUtilCli.cpp
index 434e4dd..5928088 100644
--- a/core/sql/executor/ExExeUtilCli.cpp
+++ b/core/sql/executor/ExExeUtilCli.cpp
@@ -2087,7 +2087,7 @@
Lng32 ExeCliInterface::commitWork()
{
- return executeImmediate("commit work waited;");
+ return executeImmediate("commit work;");
}
Lng32 ExeCliInterface::rollbackWork()
diff --git a/core/sql/executor/ex_transaction.cpp b/core/sql/executor/ex_transaction.cpp
index f2b2fb0..fcb5141 100644
--- a/core/sql/executor/ex_transaction.cpp
+++ b/core/sql/executor/ex_transaction.cpp
@@ -68,8 +68,7 @@
autoCommitDisabled_(FALSE),
savepointId_(0),
volatileSchemaExists_(FALSE),
- dp2Xns_(FALSE)
- ,transtag_(-1)
+ transtag_(-1)
{
transMode_ = new(heap) TransMode(TransMode::SERIALIZABLE_,
TransMode::READ_WRITE_,
@@ -85,7 +84,6 @@
if (userTransMode_)
NADELETE(userTransMode_, TransMode, heap_);
userTransMode_ = 0;
- dp2Xns_ = FALSE;
heap_ = NULL;
}
@@ -224,41 +222,6 @@
return 0;
}
-
-short ExTransaction::waitForCommitCompletion(Int64 transid)
-{
- // if (transMode_->rollbackMode() == TransMode::ROLLBACK_MODE_NOWAITED_)
- // return 0;
-
- short status;
- short rc = 0;
-
- if (transid)
- rc = STATUSTRANSACTION(&status, transid); // using param transid
- else
- rc = STATUSTRANSACTION(&status); // using current transid
- if ((rc == 0) && (status != 3))
- {
- // check for return status in a loop until the transaction
- // is aborted.
- Lng32 delayTime = 1; // units of 1/100th of a seconds.
- NABoolean done = FALSE;
- while (! done)
- {
- DELAY(delayTime);
- delayTime *= 2;
- if (transid)
- rc = STATUSTRANSACTION(&status, transid); // using param transid.
- else
- rc = STATUSTRANSACTION(&status); // using current transid
- if (! ((rc == 0) && (status != 3)))
- done = TRUE;
- }
- }
-
- return 0;
-}
-
static void setSpecialAIValues(Lng32 &aivalue)
{
// on Linux we get these definitions from tm.h
@@ -310,8 +273,6 @@
short ExTransaction::beginTransaction()
{
- dp2Xns_ = FALSE;
-
if (xnInProgress())
{
// Set the transaDiagsArea.
@@ -453,8 +414,6 @@
short ExTransaction::rollbackStatement()
{
- dp2Xns_ = FALSE;
-
if (! xnInProgress())
{
if (transDiagsArea_)
@@ -493,8 +452,6 @@
//This method does nowaited rollback transaction.
short ExTransaction::rollbackTransaction(NABoolean isWaited)
{
- dp2Xns_ = FALSE;
-
if (! xnInProgress())
{
if (transDiagsArea_)
@@ -551,8 +508,6 @@
{
Int32 rc = 0;
- dp2Xns_ = FALSE;
-
if (! xnInProgress())
{
if (transDiagsArea_)
@@ -641,10 +596,8 @@
resetXnState();
}
-short ExTransaction::commitTransaction(NABoolean waited)
+short ExTransaction::commitTransaction()
{
- dp2Xns_ = FALSE;
-
if (! xnInProgress())
{
// Set the transaDiagsArea.
@@ -699,10 +652,7 @@
//calling DEALLOCATE_ERR so memory of allocated error str
//is deallocated appropriately.
DEALLOCATE_ERR(errStr);
-
- if (waited)
- waitForCommitCompletion(transid_);
-
+
resetXnState();
return rc;
@@ -1201,7 +1151,7 @@
castToExMasterStmtGlobals()->getStatement()->
getContext()->closeAllCursors(ContextCli::CLOSE_ALL, ContextCli::CLOSE_CURR_XN);
- rc = ta->commitTransaction(FALSE);
+ rc = ta->commitTransaction();
if (rc != 0)
handleErrors(pentry_down, ta->getDiagsArea());
@@ -1231,51 +1181,6 @@
}
break;
- case COMMIT_WAITED_: {
- if (ta->userEndedExeXn()) {
- ta->cleanupTransaction();
- handleErrors(pentry_down, NULL,
- (ExeErrorCode)(-CLI_USER_ENDED_XN_CLEANUP));
-
- break;
- }
-
- // close all open cursors that are part of this xn-- ANSI requirement.
- // get current context and close all statements.
- getGlobals()->castToExExeStmtGlobals()->
- castToExMasterStmtGlobals()->getStatement()->
- getContext()->closeAllCursors(ContextCli::CLOSE_ALL, ContextCli::CLOSE_CURR_XN);
-
- rc = ta->commitTransaction(TRUE);
- if (rc != 0)
- handleErrors(pentry_down, ta->getDiagsArea());
-
- if (cliGlobals->currContext()->ddlStmtsExecuted())
- {
- ComDiagsArea * diagsArea = NULL;
- ExSqlComp::ReturnStatus cmpStatus =
- cliGlobals->currContext()->sendXnMsgToArkcmp
- (NULL, 0,
- EXSQLCOMP::DDL_NATABLE_INVALIDATE,
- diagsArea);
- if (cmpStatus == ExSqlComp::ERROR)
- {
- cliGlobals->currContext()->ddlStmtsExecuted() = FALSE;
-
- handleErrors(pentry_down, NULL,
- (ExeErrorCode)(-EXE_CANT_COMMIT_OR_ROLLBACK));
-
- return -1;
- }
- }
-
- cliGlobals->currContext()->ddlStmtsExecuted() = FALSE;
-
- // if user had specified AUTO COMMIT, turn it back on.
- ta->enableAutoCommit();
- }
- break;
-
case ROLLBACK_: {
if (ta->userEndedExeXn()) {
ta->cleanupTransaction();
diff --git a/core/sql/executor/ex_transaction.h b/core/sql/executor/ex_transaction.h
index 6fc1526..1a6b049 100644
--- a/core/sql/executor/ex_transaction.h
+++ b/core/sql/executor/ex_transaction.h
@@ -84,8 +84,7 @@
short waitForRollbackCompletion(Int64 transid);
void cleanupTransaction();
- short commitTransaction(NABoolean waited = FALSE);
- short waitForCommitCompletion(Int64 transid);
+ short commitTransaction();
short inheritTransaction();
short validateTransaction();
@@ -194,13 +193,6 @@
NABoolean mayHoldLock() { return mayHoldLock_; }
- void setDp2Xns(NABoolean x)
- {
- dp2Xns_ = x;
- }
-
- NABoolean dp2Xns() { return dp2Xns_; }
-
void resetXnState();
private:
@@ -296,15 +288,6 @@
// Two flags that help track whether a transaction can be suspended.
NABoolean mayAlterDb_;
NABoolean mayHoldLock_;
-
- // if set to TRUE, then dp2 transactions are allowed. DP2 transactions
- // are currently allowed for single row unique queries which are being
- // executed in auto commit mode. It could be either implicit autocommit
- // where exe commits the Xn at the end, or explicit autocommit mode where
- // the app commits the Xn after each stmt.
- // If they are allowed, then their use is determined in PartitionAccess
- // operator based on other conditions.
- NABoolean dp2Xns_;
int transtag_;
};
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 1d5ca35..e56b4ce 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -21283,22 +21283,6 @@
{
$$ = new (PARSERHEAP()) RelTransaction(COMMIT_);
}
- | TOK_COMMIT TOK_NO TOK_WAITED
- {
- $$ = new (PARSERHEAP()) RelTransaction(COMMIT_);
- }
- | TOK_COMMIT TOK_WORK TOK_NO TOK_WAITED
- {
- $$ = new (PARSERHEAP()) RelTransaction(COMMIT_);
- }
- | TOK_COMMIT TOK_WAITED
- {
- $$ = new (PARSERHEAP()) RelTransaction(COMMIT_WAITED_);
- }
- | TOK_COMMIT TOK_WORK TOK_WAITED
- {
- $$ = new (PARSERHEAP()) RelTransaction(COMMIT_WAITED_);
- }
| TOK_ET
{
$$ = new (PARSERHEAP()) RelTransaction(COMMIT_);
diff --git a/core/sql/qmscommon/QRQueries.cpp b/core/sql/qmscommon/QRQueries.cpp
index 84236cb..c89378b 100644
--- a/core/sql/qmscommon/QRQueries.cpp
+++ b/core/sql/qmscommon/QRQueries.cpp
@@ -674,7 +674,6 @@
to abort any implicit transactions started by cli */
SQLTRANS_ROLLBACK_IMPLICIT_XN = 8,
- SQLTRANS_BEGIN_WITH_DP2_XNS = 9
};
/* specifies the type/format of an AUTHID */
diff --git a/core/sql/sqlci/SqlciCmd.cpp b/core/sql/sqlci/SqlciCmd.cpp
index 621022f..fa0f3d1 100644
--- a/core/sql/sqlci/SqlciCmd.cpp
+++ b/core/sql/sqlci/SqlciCmd.cpp
@@ -634,7 +634,7 @@
{
case 'y':
case 'Y':
- SqlCmd::executeQuery("COMMIT WORK WAITED;", sqlci_env);
+ SqlCmd::executeQuery("COMMIT WORK;", sqlci_env);
sqlci_env->get_logfile()->WriteAll("Transaction committed."); //##I18N
retval = -1;
break;