trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [1/2] incubator-trafodion git commit: [TRAFODION-2331] UPD STATS sometimes fails silently after some other failure
Date Thu, 03 Nov 2016 22:37:38 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master cc296281f -> 294b8c6d6


[TRAFODION-2331] UPD STATS sometimes fails silently after some other failure


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/9e37d9c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/9e37d9c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/9e37d9c2

Branch: refs/heads/master
Commit: 9e37d9c22c74daee32399dac42f84c43f7141c5e
Parents: 9c712a4
Author: Dave Birdsall <dbirdsall@apache.org>
Authored: Thu Nov 3 16:46:05 2016 +0000
Committer: Dave Birdsall <dbirdsall@apache.org>
Committed: Thu Nov 3 16:46:05 2016 +0000

----------------------------------------------------------------------
 core/sql/ustat/hs_cli.cpp | 50 +++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/9e37d9c2/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index 26e5958..75bf673 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -391,8 +391,17 @@ Lng32 HSFuncExecDDL( const char *dml
   HSTranMan *TM;
   NABoolean startedTrans = FALSE;
   TM = HSTranMan::Instance();
-  startedTrans = (((retcode = TM->Begin("DDL")) == 0) ? TRUE : FALSE);
-  HSHandleError(retcode);
+  {
+    // This HSErrorCatcher is in its own block so we'll report a
+    // diagnostic in case the TM->Begin call fails. Note that
+    // HSFuncExecQuery contains its own HSErrorCatcher, so that 
+    // code is outside this block. (If we included it in this
+    // block then any error encountered there would be reported
+    // twice.)
+    HSErrorCatcher errorCatcher(retcode, sqlcode, errorToken, TRUE);
+    startedTrans = (((retcode = TM->Begin("DDL")) == 0) ? TRUE : FALSE);    
+    HSHandleError(retcode);
+  }
 
   //Special parser flags needed to use the NO AUDIT option.
   retcode = HSFuncExecQuery(dml, sqlcode, rowsAffected, errorToken,
@@ -964,14 +973,9 @@ Lng32 HSTranMan::Begin(const char *title)
         if (NOT transStarted_ &&
             NOT (extTrans_ = ((SQL_EXEC_Xact(SQLTRANS_STATUS, 0) == 0) ? TRUE : FALSE)))
           {
-#ifdef NA_USTAT_USE_STATIC
-            HSCliStatement begn(HSCliStatement::BEGINWORK);
-            retcode_ = begn.execFetch("BEGIN WORK;");
-#else
             NAString stmtText = "BEGIN WORK";
             retcode_ = HSFuncExecQuery(stmtText.data(), - UERR_INTERNAL_ERROR, NULL,
                                        HS_QUERY_ERROR, NULL, NULL, TRUE);
-#endif // NA_USTAT_USE_STATIC
             if (retcode_ >= 0)
               {
                 transStarted_ = TRUE;
@@ -1024,15 +1028,9 @@ Lng32 HSTranMan::Commit()
       {
         if (transStarted_)                         /*== COMMIT TRANSACTION ==*/
           {
-#ifdef NA_USTAT_USE_STATIC
-            HSCliStatement comt(HSCliStatement::COMMITWORK);
-            //logXactCode("before COMMIT WORK");
-            retcode_ = comt.execFetch("COMMIT WORK;");
-#else
             NAString stmtText = "COMMIT WORK";
             retcode_ = HSFuncExecQuery(stmtText.data(), - UERR_INTERNAL_ERROR, NULL,
                                        HS_QUERY_ERROR, NULL, NULL, TRUE);
-#endif // NA_USTAT_USE_STATIC
 
             // transaction has ended
             transStarted_ = FALSE;
@@ -1097,20 +1095,28 @@ Lng32 HSTranMan::Rollback()
       {
         if (transStarted_)                         /*==ROLLBACK TRANSACTION==*/
           {
-#ifdef NA_USTAT_USE_STATIC
-            HSCliStatement robk(HSCliStatement::ROBACKWORK);
-            retcode_ = robk.execFetch("ROLLBACK WORK");
-#else
             NAString stmtText = "ROLLBACK WORK";
             retcode_ = HSFuncExecQuery(stmtText.data(), - UERR_INTERNAL_ERROR, NULL,
                                        HS_QUERY_ERROR, NULL, NULL, TRUE);
-#endif // NA_USTAT_USE_STATIC
             // transaction has ended
             transStarted_ = FALSE;
-            if (retcode_ >= 0) {
-              retcode_ = 0;
-              LM->Log("ROLLBACK()");
-            }
+            if (retcode_ < 0)
+              {
+                // The rollback may have failed because the Executor already
+                // aborted the transaction.
+                if (!InTransaction())
+                  retcode_ = 0;  // just ignore the error
+                else
+                  {
+                    snprintf(LM->msg, sizeof(LM->msg), "ROBACKWORK failed, retcode_:
%d)", retcode_);
+                    LM->Log(LM->msg);
+                  }
+              }
+            if (retcode_ >= 0) 
+              {
+                retcode_ = 0;
+                LM->Log("ROLLBACK()");
+              }
           }
         else
           {                                      /*==NO TRANSACTION RUNNING==*/


Mime
View raw message