Changes to handle errors during drop of lob tables that leave the table inconsistent. (cherry picked from commit 749295ad774620d49db79d961b1bbacac8d589c7)
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/e8c09ebb Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/e8c09ebb Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/e8c09ebb Branch: refs/heads/master Commit: e8c09ebb678ab6560130bf687dc1e52c9b04d64a Parents: f186448 Author: Sandhya Sundaresan <[email protected]> Authored: Mon Sep 11 17:57:02 2017 +0000 Committer: Sandhya Sundaresan <[email protected]> Committed: Mon Sep 11 17:57:02 2017 +0000 ---------------------------------------------------------------------- core/sql/cli/Cli.cpp | 48 ++++++++++++++++------------ core/sql/sqlcomp/CmpSeabaseDDLtable.cpp | 5 ++- 2 files changed, 31 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/e8c09ebb/core/sql/cli/Cli.cpp ---------------------------------------------------------------------- diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp index a25a31b..cd1c852 100644 --- a/core/sql/cli/Cli.cpp +++ b/core/sql/cli/Cli.cpp @@ -10519,7 +10519,7 @@ Lng32 SQLCLI_LOB_GC_Interface if (rc ) { - cliRC = 9999; // Warning + cliRC = 1; // Warning ComDiagsArea * da = &diags; lobDebugInfo("compactLobDataFile Failed",0,__LINE__,lobTrace); @@ -10667,7 +10667,7 @@ Lng32 SQLCLI_LOBddlInterface if (rc) { - cliRC = -9999; + cliRC = 0; ComDiagsArea * da = &diags; ExRaiseSqlError(currContext.exHeap(), &da, (ExeErrorCode)(8442), NULL, &cliRC , @@ -10734,22 +10734,7 @@ Lng32 SQLCLI_LOBddlInterface // drop descriptor table for (Lng32 i = 0; i < numLOBs; i++) - { - Lng32 rc = ExpLOBoper::dropLOB - (NULL, currContext.exHeap(),(void *)&currContext, - lobLocList[i],hdfsPort,hdfsServer, - objectUID, lobNumList[i]); - - if (rc) - { - cliRC = -9999; - ComDiagsArea * da = &diags; - ExRaiseSqlError(currContext.exHeap(), &da, - (ExeErrorCode)(8442), NULL, &cliRC , - &rc, NULL, (char*)"ExpLOBInterfaceDrop ", - getLobErrStr(rc)); - goto error_return; - } + { // drop LOB descriptor and LOB header tables char lobHandle[LOB_HANDLE_LEN]; @@ -10782,7 +10767,28 @@ Lng32 SQLCLI_LOBddlInterface } } // for - + //If all the descriptor tables got dropped correctly, drop the hdfs + //lob data files. Note that if there is an error in the drop of the + //descriptor tables above , the transaction will restore each of the + //above tables . + for (Lng32 i = 0; i < numLOBs; i++) + { + Lng32 rc = ExpLOBoper::dropLOB + (NULL, currContext.exHeap(),(void *)&currContext, + lobLocList[i],hdfsPort,hdfsServer, + objectUID, lobNumList[i]); + // Ignore 'not found' error from hdfs file deletes until this is made transactional just like Hbase tables are. + if (rc && (rc != -LOB_DATA_FILE_DELETE_ERROR)) + { + cliRC = -1; + ComDiagsArea * da = &diags; + ExRaiseSqlError(currContext.exHeap(), &da, + (ExeErrorCode)(8442), NULL, &cliRC , + &rc, NULL, (char*)"ExpLOBInterfaceDrop ", + getLobErrStr(rc)); + goto error_return; + } + }//for } break; @@ -10813,9 +10819,9 @@ Lng32 SQLCLI_LOBddlInterface lobLocList[i],hdfsPort, hdfsServer, objectUID, lobNumList[i]); - if (rc) + if (rc && rc != -LOB_DATA_FILE_DELETE_ERROR) { - cliRC = -9999; + cliRC = -1; ComDiagsArea * da = &diags; ExRaiseSqlError(currContext.exHeap(), &da, (ExeErrorCode)(8442), NULL, &cliRC , http://git-wip-us.apache.org/repos/asf/trafodion/blob/e8c09ebb/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp ---------------------------------------------------------------------- diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp index 3cdd063..726a866 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp @@ -2929,7 +2929,8 @@ short CmpSeabaseDDL::createSeabaseTable2( if (rc < 0) { - //sss TBD need to retrive the cli diags here. + // retrieve the cli diags here. + CmpCommon::diags()->mergeAfter(*(GetCliGlobals()->currContext()->getDiagsArea())); *CmpCommon::diags() << DgSqlCode(-CAT_CREATE_OBJECT_ERROR) << DgTableName(extTableName); deallocEHI(ehi); @@ -4403,6 +4404,8 @@ short CmpSeabaseDDL::dropSeabaseTable2( lobLocList,NULL,lobHdfsServer, lobHdfsPort,0,lobTrace); if (rc < 0) { + // retrieve the cli diags here. + CmpCommon::diags()->mergeAfter( *(GetCliGlobals()->currContext()->getDiagsArea())); *CmpCommon::diags() << DgSqlCode(-CAT_UNABLE_TO_DROP_OBJECT) << DgTableName(extTableName); deallocEHI(ehi);
