Comment 2 for bug 1426479

Revision history for this message
Justin Du (justin-du-2) wrote :

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