More info about the problem analysis from email exchanges:
The problem seems with switching CmpContext. Here is the scenario:
1) We executed the drop seabase table statement, we set cqd HIDE_INDEXES ‘NONE’ at sqlcomp/CmpSeabaseDDLcommon.cpp:6620.
2) However, when we started dropping the seabase table at line 6740, we went through a binder step to get the NATable info,
3) Since we were in the embedded CmpContext when doing all this and the getNATable call somehow needs to compile statements to get the table info, this caused CmpContext switch,
4) When switching back, we called restoreAllControlsAndFlags() and that caused the external compiler to reset the cqd HIDE_INDEXES to ‘ALL’.
5) Later we compiled the delete statement, the compilation was sent to the external compiler (as we were already in the embedded compiler) thus the returned plan didn’t include the index part.
Here is the stacks info that shows 2) to 4) . I had observed that 3) didn’t happen sometimes. In that case, the delete statement would be right.
I hope we can find the solution from this call path.
Thanks,
Justin
(gdb) bt
#0 ExControlTcb::work (this=0x7fffe8ab8600) at ../executor/ex_control.cpp:191
#1 0x00007ffff485369b in ex_tcb::sWork (tcb=0x7fffe8ab8600)
at ../executor/ex_tcb.h:99
#2 0x00007ffff49bdd67 in ExSubtask::work (this=0x7fffe8ab8b38)
at ../executor/ExScheduler.cpp:751
#3 0x00007ffff49bd12a in ExScheduler::work (this=0x7fffe8ab8240,
prevWaitTime=0) at ../executor/ExScheduler.cpp:328
#4 0x00007ffff48aa3a2 in ex_root_tcb::execute (this=0x7fffe8ab8bb8,
cliGlobals=0xb84880, glob=0x7fffe8ab47a0, input_desc=0x7fffe8ae1030,
diagsArea=@0x7ffffffe86d0, reExecute=0) at ../executor/ex_root.cpp:1055
#5 0x00007ffff5ef63db in CliStatement::execute (this=0x7fffe8ae0168,
cliGlobals=0xb84880, input_desc=0x7fffe8ae1030, diagsArea=...,
execute_state=CliStatement::INITIAL_STATE_, fixupOnly=0, cliflags=0)
at ../cli/Statement.cpp:4570
#6 0x00007ffff5e7fc7f in SQLCLI_PerformTasks(CliGlobals *, ULng32, SQLSTMT_ID *, SQLDESC_ID *, SQLDESC_ID *, Lng32, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *, SQLCLI_PTR_PAIRS *) (cliGlobals=0xb84880, tasks=4882,
statement_id=0x10d5f40, input_descriptor=0x1bbddc0, output_descriptor=0x0,
num_input_ptr_pairs=0, num_output_ptr_pairs=0, ap=0x7ffffffe8cb0,
input_ptr_pairs=0x0, output_ptr_pairs=0x0) at ../cli/Cli.cpp:3284
#7 0x00007ffff5e805f0 in SQLCLI_Exec(CliGlobals *, SQLSTMT_ID *, SQLDESC_ID *, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *) (
cliGlobals=0xb84880, statement_id=0x10d5f40, input_descriptor=0x1bbddc0,
num_ptr_pairs=0, ap=0x7ffffffe8cb0, ptr_pairs=0x0) at ../cli/Cli.cpp:3531
#8 0x00007ffff5f0b938 in SQL_EXEC_Exec (statement_id=0x10d5f40,
input_descriptor=0x1bbddc0, num_ptr_pairs=0) at ../cli/CliExtern.cpp:2071
#9 0x00007ffff49232b0 in ExeCliInterface::exec (this=0x7ffffffe90e0,
inputBuf=0x0, inputBufLen=0) at ../executor/ExExeUtilCli.cpp:616
#10 0x00007ffff4923e6a in ExeCliInterface::executeImmediateExec (
this=0x7ffffffe90e0,
stmtStr=0x7ffffffe8f00 "control query default hide_indexes reset;",
outputBuf=0x0, outputBufLen=0x0, nullTerminate=1, rowsAffected=0x0)
at ../executor/ExExeUtilCli.cpp:915
#11 0x00007ffff4924165 in ExeCliInterface::executeImmediate (
this=0x7ffffffe90e0,
stmtStr=0x7ffffffe8f00 "control query default hide_indexes reset;",
outputBuf=0x0, outputBufLen=0x0, nullTerminate=1, rowsAffected=0x0,
monitorThis=0, globalDiags=0x0) at ../executor/ExExeUtilCli.cpp:1010
#12 0x00007ffff49269ad in ExeCliInterface::restoreCQD (this=0x7ffffffe90e0,
defaultName=0x7ffff0c054f6 "hide_indexes", globalDiags=0x0)
at ../executor/ExExeUtilCli.cpp:2105
#13 0x00007ffff0ae1ecf in CmpSeabaseDDL::restoreAllControlsAndFlags (
this=0x7ffffffe9370) at ../sqlcomp/CmpSeabaseDDLcommon.cpp:1347
#14 0x00007ffff0add74a in CmpSeabaseDDL::switchBackCompiler (
this=0x7ffffffe9370) at ../sqlcomp/CmpSeabaseDDLcommon.cpp:157
#15 0x00007ffff0b53963 in CmpSeabaseDDL::getSeabaseTableDesc (
this=0x7ffffffe9370, catName=..., schName=..., objName=...,
objType=COM_BASE_TABLE_OBJECT, includeInvalidDefs=0)
at ../sqlcomp/CmpSeabaseDDLtable.cpp:7630
#16 0x00007fffef109341 in NATableDB::get (this=0x7fffe7f146b8, corrName=...,
bindWA=0x7ffffffebdf0, inTableDescStruct=0x0)
at ../optimizer/NATable.cpp:8070
#17 0x00007fffeee4c064 in BindWA::getNATable (this=0x7ffffffebdf0,
corrName=..., catmanCollectTableUsages=1, inTableDescStruct=0x0)
at ../optimizer/BindRelExpr.cpp:1448
#18 0x00007ffff0b390e9 in CmpSeabaseDDL::dropSeabaseTable (
this=0x7ffffffef830, dropTableNode=0x7fffd66c0870, currCatName=...,
currSchName=...) at ../sqlcomp/CmpSeabaseDDLtable.cpp:2327
#19 0x00007ffff0af7e59 in CmpSeabaseDDL::executeSeabaseDDL (
this=0x7ffffffef830, ddlExpr=0x7fffd66c0a58, ddlNode=0x7fffd66c0870,
currCatName=..., currSchName=...)
at ../sqlcomp/CmpSeabaseDDLcommon.cpp:6740
#20 0x00007ffff547f806 in CmpStatement::process (this=0x7fffd66fb1a8,
statement=...) at ../arkcmp/CmpStatement.cpp:931
#21 0x00007ffff546e473 in CmpContext::compileDirect (this=0x7fffe7f0f090,
data=0x7fffe8ac5fc8 "\200", data_len=176, outHeap=0x7fffe9515138,
charset=15, op=CmpMessageObj::PROCESSDDL, gen_code=@0x7fffffff01b8,
gen_code_len=@0x7fffffff01b4, parserFlags=0, diagsArea=0x7fffe8ac6080)
at ../arkcmp/CmpContext.cpp:720
#22 0x00007ffff4836346 in ExDDLTcb::work (this=0x7fffe8aa9c70)
at ../executor/ex_ddl.cpp:265
#23 0x00007ffff485369b in ex_tcb::sWork (tcb=0x7fffe8aa9c70)
at ../executor/ex_tcb.h:99
#24 0x00007ffff49bdd67 in ExSubtask::work (this=0x7fffe8aaa1c8)
at ../executor/ExScheduler.cpp:751
#25 0x00007ffff49bd12a in ExScheduler::work (this=0x7fffe8aa97d8,
prevWaitTime=0) at ../executor/ExScheduler.cpp:328
#26 0x00007ffff48aa3a2 in ex_root_tcb::execute (this=0x7fffe8aaa248,
cliGlobals=0xb84880, glob=0x7fffe8ac5990, input_desc=0x7fffe8adff70,
diagsArea=@0x7fffffff17f0, reExecute=0) at ../executor/ex_root.cpp:1055
#27 0x00007ffff5ef63db in CliStatement::execute (this=0x7fffe8ac7d20,
cliGlobals=0xb84880, input_desc=0x7fffe8adff70, diagsArea=...,
execute_state=CliStatement::INITIAL_STATE_, fixupOnly=0, cliflags=0)
at ../cli/Statement.cpp:4570
#28 0x00007ffff5e7fc7f in SQLCLI_PerformTasks(CliGlobals *, ULng32, SQLSTMT_ID *, SQLDESC_ID *, SQLDESC_ID *, Lng32, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *, SQLCLI_PTR_PAIRS *) (cliGlobals=0xb84880, tasks=4882,
statement_id=0xbe9130, input_descriptor=0xcea660, output_descriptor=0x0,
num_input_ptr_pairs=0, num_output_ptr_pairs=0, ap=0x7fffffff1dd0,
input_ptr_pairs=0x0, output_ptr_pairs=0x0) at ../cli/Cli.cpp:3284
#29 0x00007ffff5e805f0 in SQLCLI_Exec(CliGlobals *, SQLSTMT_ID *, SQLDESC_ID *, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *) (
cliGlobals=0xb84880, statement_id=0xbe9130, input_descriptor=0xcea660,
num_ptr_pairs=0, ap=0x7fffffff1dd0, ptr_pairs=0x0) at ../cli/Cli.cpp:3531
#30 0x00007ffff5f0b938 in SQL_EXEC_Exec (statement_id=0xbe9130,
input_descriptor=0xcea660, num_ptr_pairs=0) at ../cli/CliExtern.cpp:2071
#31 0x00007ffff79b4434 in SqlCmd::doExec (sqlci_env=0xb83620, stmt=0xbe9130,
prep_stmt=0x1e67e90, numUnnamedParams=0, unnamedParamArray=0x0,
unnamedParamCharSetArray=0x0, handleError=1) at ../sqlci/SqlCmd.cpp:1706
#32 0x00007ffff79b522a in SqlCmd::do_execute (sqlci_env=0xb83620,
prep_stmt=0x1e67e90, numUnnamedParams=0, unnamedParamArray=0x0,
unnamedParamCharSetArray=0x0, prepcode=0) at ../sqlci/SqlCmd.cpp:2042
#33 0x00007ffff79b752b in DML::process (this=0x163e790, sqlci_env=0xb83620)
at ../sqlci/SqlCmd.cpp:2816
#34 0x00007ffff79abcf6 in FixCommand::process (this=0x1e4ce70,
sqlci_env=0xb83620) at ../sqlci/SqlciStmts.cpp:505
#35 0x00007ffff79a19ae in SqlciEnv::executeCommands (this=0xb83620,
input_stmt=@0x7fffffff38a8) at ../sqlci/SqlciEnv.cpp:847
#36 0x00007ffff79a10ef in SqlciEnv::run (this=0xb83620)
at ../sqlci/SqlciEnv.cpp:656
#37 0x0000000000402089 in main (argc=1, argv=0x7fffffff3a68)
at ../bin/SqlciMain.cpp:328
More info about the problem analysis from email exchanges:
The problem seems with switching CmpContext. Here is the scenario:
1) We executed the drop seabase table statement, we set cqd HIDE_INDEXES ‘NONE’ at sqlcomp/ CmpSeabaseDDLco mmon.cpp: 6620. olsAndFlags( ) and that caused the external compiler to reset the cqd HIDE_INDEXES to ‘ALL’.
2) However, when we started dropping the seabase table at line 6740, we went through a binder step to get the NATable info,
3) Since we were in the embedded CmpContext when doing all this and the getNATable call somehow needs to compile statements to get the table info, this caused CmpContext switch,
4) When switching back, we called restoreAllContr
5) Later we compiled the delete statement, the compilation was sent to the external compiler (as we were already in the embedded compiler) thus the returned plan didn’t include the index part.
Here is the stacks info that shows 2) to 4) . I had observed that 3) didn’t happen sometimes. In that case, the delete statement would be right.
I hope we can find the solution from this call path.
Thanks,
Justin
(gdb) bt b8600) at ../executor/ ex_control. cpp:191 8600) ex_tcb. h:99 b8b38) ExScheduler. cpp:751 b8240, ExScheduler. cpp:328 tcb::execute (this=0x7fffe8a b8bb8, 0xb84880, glob=0x7fffe8ab 47a0, input_desc= 0x7fffe8ae1030, @0x7ffffffe86d0 , reExecute=0) at ../executor/ ex_root. cpp:1055 :execute (this=0x7fffe8a e0168, 0xb84880, input_desc= 0x7fffe8ae1030, diagsArea=..., state=CliStatem ent::INITIAL_ STATE_, fixupOnly=0, cliflags=0) Statement. cpp:4570 PerformTasks( CliGlobals *, ULng32, SQLSTMT_ID *, SQLDESC_ID *, SQLDESC_ID *, Lng32, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *, SQLCLI_PTR_PAIRS *) (cliGlobals= 0xb84880, tasks=4882, id=0x10d5f40, input_descripto r=0x1bbddc0, output_ descriptor= 0x0, input_ptr_ pairs=0, num_output_ ptr_pairs= 0, ap=0x7ffffffe8cb0, ptr_pairs= 0x0, output_ ptr_pairs= 0x0) at ../cli/Cli.cpp:3284 Exec(CliGlobals *, SQLSTMT_ID *, SQLDESC_ID *, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *) ( 0xb84880, statement_ id=0x10d5f40, input_descripto r=0x1bbddc0, ptr_pairs= 0, ap=0x7ffffffe8cb0, ptr_pairs=0x0) at ../cli/Cli.cpp:3531 id=0x10d5f40, descriptor= 0x1bbddc0, num_ptr_pairs=0) at ../cli/ CliExtern. cpp:2071 ::exec (this=0x7ffffff e90e0, ExExeUtilCli. cpp:616 ::executeImmedi ateExec ( 0x7ffffffe90e0, 0x7ffffffe8f00 "control query default hide_indexes reset;", ExExeUtilCli. cpp:915 ::executeImmedi ate ( 0x7ffffffe90e0, 0x7ffffffe8f00 "control query default hide_indexes reset;", ExExeUtilCli. cpp:1010 ::restoreCQD (this=0x7ffffff e90e0, =0x7ffff0c054f6 "hide_indexes", globalDiags=0x0) ExExeUtilCli. cpp:2105 :restoreAllCont rolsAndFlags ( 0x7ffffffe9370) at ../sqlcomp/ CmpSeabaseDDLco mmon.cpp: 1347 :switchBackComp iler ( 0x7ffffffe9370) at ../sqlcomp/ CmpSeabaseDDLco mmon.cpp: 157 :getSeabaseTabl eDesc ( 0x7ffffffe9370, catName=..., schName=..., objName=..., COM_BASE_ TABLE_OBJECT, includeInvalidD efs=0) CmpSeabaseDDLta ble.cpp: 7630 146b8, corrName=..., 0x7ffffffebdf0, inTableDescStru ct=0x0) NATable. cpp:8070 ebdf0, bleUsages= 1, inTableDescStru ct=0x0) BindRelExpr. cpp:1448 :dropSeabaseTab le ( 0x7ffffffef830, dropTableNode= 0x7fffd66c0870, currCatName=..., =...) at ../sqlcomp/ CmpSeabaseDDLta ble.cpp: 2327 :executeSeabase DDL ( 0x7ffffffef830, ddlExpr= 0x7fffd66c0a58, ddlNode= 0x7fffd66c0870, =..., currSchName=...) CmpSeabaseDDLco mmon.cpp: 6740 :process (this=0x7fffd66 fb1a8, CmpStatement. cpp:931 :compileDirect (this=0x7fffe7f 0f090, 0x7fffe8ac5fc8 "\200", data_len=176, outHeap= 0x7fffe9515138, j::PROCESSDDL, gen_code= @0x7fffffff01b8 , code_len= @0x7fffffff01b4 , parserFlags=0, diagsArea= 0x7fffe8ac6080) CmpContext. cpp:720 a9c70) ex_ddl. cpp:265 9c70) ex_tcb. h:99 aa1c8) ExScheduler. cpp:751 a97d8, ExScheduler. cpp:328 tcb::execute (this=0x7fffe8a aa248, 0xb84880, glob=0x7fffe8ac 5990, input_desc= 0x7fffe8adff70, @0x7fffffff17f0 , reExecute=0) at ../executor/ ex_root. cpp:1055 :execute (this=0x7fffe8a c7d20, 0xb84880, input_desc= 0x7fffe8adff70, diagsArea=..., state=CliStatem ent::INITIAL_ STATE_, fixupOnly=0, cliflags=0) Statement. cpp:4570 PerformTasks( CliGlobals *, ULng32, SQLSTMT_ID *, SQLDESC_ID *, SQLDESC_ID *, Lng32, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *, SQLCLI_PTR_PAIRS *) (cliGlobals= 0xb84880, tasks=4882, id=0xbe9130, input_descripto r=0xcea660, output_ descriptor= 0x0, input_ptr_ pairs=0, num_output_ ptr_pairs= 0, ap=0x7fffffff1dd0, ptr_pairs= 0x0, output_ ptr_pairs= 0x0) at ../cli/Cli.cpp:3284 Exec(CliGlobals *, SQLSTMT_ID *, SQLDESC_ID *, Lng32, typedef __va_list_tag __va_list_tag *, SQLCLI_PTR_PAIRS *) ( 0xb84880, statement_ id=0xbe9130, input_descripto r=0xcea660, ptr_pairs= 0, ap=0x7fffffff1dd0, ptr_pairs=0x0) at ../cli/Cli.cpp:3531 id=0xbe9130, descriptor= 0xcea660, num_ptr_pairs=0) at ../cli/ CliExtern. cpp:2071 env=0xb83620, stmt=0xbe9130, stmt=0x1e67e90, numUnnamedParams=0, unnamedParamArr ay=0x0, mCharSetArray= 0x0, handleError=1) at ../sqlci/ SqlCmd. cpp:1706 env=0xb83620, stmt=0x1e67e90, numUnnamedParams=0, unnamedParamArr ay=0x0, mCharSetArray= 0x0, prepcode=0) at ../sqlci/ SqlCmd. cpp:2042 SqlCmd. cpp:2816 env=0xb83620) at ../sqlci/ SqlciStmts. cpp:505 :executeCommand s (this=0xb83620, stmt=@0x7ffffff f38a8) at ../sqlci/ SqlciEnv. cpp:847 SqlciEnv. cpp:656 3a68) SqlciMain. cpp:328
#0 ExControlTcb::work (this=0x7fffe8a
#1 0x00007ffff485369b in ex_tcb::sWork (tcb=0x7fffe8ab
at ../executor/
#2 0x00007ffff49bdd67 in ExSubtask::work (this=0x7fffe8a
at ../executor/
#3 0x00007ffff49bd12a in ExScheduler::work (this=0x7fffe8a
prevWaitTime=0) at ../executor/
#4 0x00007ffff48aa3a2 in ex_root_
cliGlobals=
diagsArea=
#5 0x00007ffff5ef63db in CliStatement:
cliGlobals=
execute_
at ../cli/
#6 0x00007ffff5e7fc7f in SQLCLI_
statement_
num_
input_
#7 0x00007ffff5e805f0 in SQLCLI_
cliGlobals=
num_
#8 0x00007ffff5f0b938 in SQL_EXEC_Exec (statement_
input_
#9 0x00007ffff49232b0 in ExeCliInterface
inputBuf=0x0, inputBufLen=0) at ../executor/
#10 0x00007ffff4923e6a in ExeCliInterface
this=
stmtStr=
outputBuf=0x0, outputBufLen=0x0, nullTerminate=1, rowsAffected=0x0)
at ../executor/
#11 0x00007ffff4924165 in ExeCliInterface
this=
stmtStr=
outputBuf=0x0, outputBufLen=0x0, nullTerminate=1, rowsAffected=0x0,
monitorThis=0, globalDiags=0x0) at ../executor/
#12 0x00007ffff49269ad in ExeCliInterface
defaultName
at ../executor/
#13 0x00007ffff0ae1ecf in CmpSeabaseDDL:
this=
#14 0x00007ffff0add74a in CmpSeabaseDDL:
this=
#15 0x00007ffff0b53963 in CmpSeabaseDDL:
this=
objType=
at ../sqlcomp/
#16 0x00007fffef109341 in NATableDB::get (this=0x7fffe7f
bindWA=
at ../optimizer/
#17 0x00007fffeee4c064 in BindWA::getNATable (this=0x7ffffff
corrName=..., catmanCollectTa
at ../optimizer/
#18 0x00007ffff0b390e9 in CmpSeabaseDDL:
this=
currSchName
#19 0x00007ffff0af7e59 in CmpSeabaseDDL:
this=
currCatName
at ../sqlcomp/
#20 0x00007ffff547f806 in CmpStatement:
statement=...) at ../arkcmp/
#21 0x00007ffff546e473 in CmpContext:
data=
charset=15, op=CmpMessageOb
gen_
at ../arkcmp/
#22 0x00007ffff4836346 in ExDDLTcb::work (this=0x7fffe8a
at ../executor/
#23 0x00007ffff485369b in ex_tcb::sWork (tcb=0x7fffe8aa
at ../executor/
#24 0x00007ffff49bdd67 in ExSubtask::work (this=0x7fffe8a
at ../executor/
#25 0x00007ffff49bd12a in ExScheduler::work (this=0x7fffe8a
prevWaitTime=0) at ../executor/
#26 0x00007ffff48aa3a2 in ex_root_
cliGlobals=
diagsArea=
#27 0x00007ffff5ef63db in CliStatement:
cliGlobals=
execute_
at ../cli/
#28 0x00007ffff5e7fc7f in SQLCLI_
statement_
num_
input_
#29 0x00007ffff5e805f0 in SQLCLI_
cliGlobals=
num_
#30 0x00007ffff5f0b938 in SQL_EXEC_Exec (statement_
input_
#31 0x00007ffff79b4434 in SqlCmd::doExec (sqlci_
prep_
unnamedPara
#32 0x00007ffff79b522a in SqlCmd::do_execute (sqlci_
prep_
unnamedPara
#33 0x00007ffff79b752b in DML::process (this=0x163e790, sqlci_env=0xb83620)
at ../sqlci/
#34 0x00007ffff79abcf6 in FixCommand::process (this=0x1e4ce70,
sqlci_
#35 0x00007ffff79a19ae in SqlciEnv:
input_
#36 0x00007ffff79a10ef in SqlciEnv::run (this=0xb83620)
at ../sqlci/
#37 0x0000000000402089 in main (argc=1, argv=0x7fffffff
at ../bin/