[ 
https://issues.apache.org/jira/browse/HAWQ-1494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

fangpei updated HAWQ-1494:
--------------------------
    Description: 
When I execute a specific sql, a serious bug can happen every time. (Hawq 
version is 2.2.0.0)

BUG information:
FATAL: Unexpect internal error (setref.c:298)
DETAIL: AssertImply failed("!(!var->varattno >= 0) || (var->varattno <= 
list_length(colNames) + list_length(rte- >pseudocols)))", File: "setrefs.c", 
Line: 298)
HINT:  Process 239600 will wait for gp_debug_linger=120 seconds before 
termination.
Note that its locks and other resources will not be released  until then.
server closed the connection unexpectedly
        This probably means the server terminated abnormally
         before or while processing the request.
The connection to the server was lost. Attemping reset: Succeeded.

I use GDB to debug, the GDB information is the same every time. The information 
is: 
Loaded symbols for /lib64/libnss_files.so.2
0x00000032dd40eb5c in recv 0 from /lib64/libpthread.so.0
(gdb) b setrefs.c:298
Breakpoint 1 at 0x846063: file setrefs.c, line 298.
(gdb) c 
Continuing.
Breakpoint 1, set_plan_references_output_asserts (glob=0x7fe96fbccab0, 
plan=0x7fe8e930adb8) at setrefs.c:298
298 set ref s .c:没有那个文件或目录.
(gdb) c 1923
Will ignore next 1922 crossings of breakpoint 1. Continuing.
Breakpoint 1, set_plan_references_output_asserts (glob=0x7fe96fbccab0, 
plan=0x7fe869c70340) at setrefs.c:298
298 in setrefs.c
(gdb) p list_length(allVars) 
$1 = 1422
(gdb) p var->varno 
$2 = 65001
(gdb) p list_length(glob->finalrtable) 
$3 = 66515
(gdb) p var->varattno 
$4 = 31
(gdb) p list_length(colNames) 
$5 = 30
(gdb) p list_length(rte->pseudocols) 
$6 = 0

the SQL sentence is just like :
SELECT *
FROM (select t.*,1001 as ttt from AAA t where  ( aaa = '320106000000006235'  or 
aaa = '320106000000006236'  or aaa = '320102000000006292'  or aaa = 
'320106000000006293'  or aaa = '32010600000006393' ) and (  bbb between 
'20170601065900' and '20170601175100'  and (ccc = '2017-06-01' ))  union all  
select t.*,1002 as ttt from AAA t where  ( aaa = '320106000000006007'  or aaa = 
'320106000000006006' ) and (  bbb between '20170601072900' and '20170601210100' 
 and ( ccc = '2017-06-01' ))  union all  select t.*,1003 as ttt from AAA t 
where  ( aaa = '320106000000002772' ) and (  bbb between '20170601072900' and 
'20170601170100'  and ( ccc = '2017-06-01' ))  union all  select t.*,1004 as 
ttt from AAA t where  (aaa = '320106000000006115'  or aaa = 
'320106000000006116'  or aaa = '320106000000006318'  or aaa = 
'320106000000006319' ) and (  bbb between '20170601085900' and '20170601163100' 
and ( ccc = '2017-06-01' ))  union all  select t.*,1005 as ttt from AAA t where 
 ( aaa = '320106000000006180' or aaa = '320104000000006385' ) and (  bbb 
between '20170601205900' and '20170601230100'  and ( ccc = '2017-06-01' )) 
union all  select t.*,1006 as ttt from AAA t where  ( aaa = 
'320102000000006423'  or aaa = '320102000000006255'  or aaa = 
'320106000000006258'  or aaa = '320106000000006259' ) and (  bbb between 
'20170601215900' and '20170602004900'  and ( ccc = '2017-06-01'  or ccc = 
'2017-06-02' ))  union all select t.*,1007 as ttt from AAA t where  ( aaa = 
'320106000000006175' or aaa = '320106000000006004' ) and (  bbb between 
'20170602074900' and '20170602182100'  and ( ccc = '2017-06-02'  )) union all 
select t.*,1008 as ttt from AAA t where  ( aaa = '320102000000006648' ) and (  
bbb between '20170602132900' and '20170602134600'  and ( ccc = '2017-06-02' ))  
union all  select t.*,1009 as ttt from AAA t where  ( aaa = 
'320106000000002765'  or aaa = '320100000000006282' ) and (  bbb between 
'20170602142900' and '20170603175100'  and ( ccc = '2017-06-02'  or ccc = 
'2017-06-03' ))  union all  select t.*,1010 as ttt from AAA t where  (aaa = 
'320106000000006060' ) and (  bbb between '20170602165900' and '20170603034100' 
 and ( ccc = '2017-06-02'  or ccc = '2017-06-03' ))  union all select t.*,1011 
as ttt from AAA t where  ( aaa = '3201060000000062229'  or aaa = 
'320106000000006230'  or aaa = '320102000000002783'  or aaa = 
'320102000000006304' ) and (  bbb between '20170603192900' and '20170604183100' 
 and ( ccc = '2017-06-03'  or ccc = '2017-06-04' ))  union all select t.*,1012 
as ttt from AAA t where  ( aaa = '320113000000006549' ) and (  bbb between 
'20170604071947' and '20170604220100'  and ( ccc = '2017-06-04' ))  union all 
select t.*1013 as ttt from AAA t where  ( aaa = '320106000000006061'  or aaa = 
'320106000000006062' ) and (  bbb between '20170604145900' and '20170604154100' 
 and ( ccc = '2017-06-04' ))  ) T0 
WHERE EXISTS (SELECT HHH
  FROM (SELECT HHH, COUNT(*)
  FROM (SELECT HHH, ttt, COUNT(*)
  FROM (select t.*,1001 as ttt from AAA t where  ( aaa = '320106000000006235'  
or aaa = '320106000000006236'  or aaa = '320102000000006292'  or aaa = 
'320106000000006293'  or aaa = '320106000000006393' ) and (  bbb between 
'20170601065900' and '20170601175100'  and ( ccc = '2017-06-01' ))  union all  
select t.*,1002 as ttt from AAA t where  ( aaa = '320106000000006007'  or aaa = 
'320106000000006006' ) and (  bbb between '20170601072900' and '20170601170100' 
 and ( ccc = '2017-06-01' ))  union all  select t.*,1003 as ttt from AAA t 
where  ( aaa = '320106000000002772' ) and ( bbb between '20170601072900' and 
'20170601170100'  and ( ccc = '2017-06-01' ))  union all  select t.*,1004 as 
ttt from AAA t where  (aaa = '320106000000006115'  or aaa = 
'320106000000006116'  or aaa = '320106000000006318'  or aaa = 
'320106000000006319' ) and (  bbb between '20170601085900' and '20170601163100' 
 and ( ccc = '2017-06-01' ))  union all select t.*,1005 as ttt from AAA t where 
 ( aaa = '320106000000006180'  or aaa = '320104000000006385' ) and (  bbb 
between '20170601205900' and '20170601230100'  and ( ccc = '2017-06-01' ))  
union all  select t.*,1006 as ttt from AAA t where  ( aaa = 
'320102000000006423'  or aaa = '320102000000006255'  or aaa = 
'320106000000006258'  or aaa = '320106000000006259' ) and (  bbb between 
'20170601215900' and '20170602004900'  and ( ccc = '2017-06-01'  or ccc = 
'2017-06-02' ))  union all  select t.*,1007 as ttt from AAA t where  ( aaa = 
'320106000000006175'  or aaa = '320106000000006004' ) and (  bbb between 
'20170602074900' and '20170602182100'  and ( ccc = '2017-06-02' ))  union all 
select t.*,1008 as ttt from AAA t where  ( aaa = '320102000000006648' ) and (  
bbb between '20170602132900' and '20170602134600'  and ( ccc = '2017-06-02' ))  
union all  select t.*,1009 as ttt from AAA t where  ( aaa = 
'320106000000002765'  or aaa = '320100000000006282' ) and (  bbb between 
'20170602142900' and '20170603175100'  and ( ccc = '2017-06-02'  or ccc = 
'2017-06-03' ))  union all select t.*,1010 as ttt from AAA t where  ( aaa = 
'320106000000006060' ) and (  bbb between '20170602165900' and '20170603034100' 
 and ( ccc = '2017-06-02'  or ccc = '2017-06-03' ))  union all select t.*,1011 
as ttt from AAA t where  ( aaa = '320106000000006229'  or aaa = 
'320106000000006230'  or aaa = '320102000000002783'  or aaa = 
'320102000000006304' ) and (  bbb between '20170603192900' and '20170604183100' 
 and ( ccc = '2017-06-03'  or ccc = '2017-06-04' ))  union all  select t.*,1012 
as ttt from AAA t where  ( aaa = '32011300000000549' ) and (  bbb between 
'20170604071947' and '20170604220100'  and ( ccc = '2017-06-04' ))  union all 
select t.*,1013 as ttt from AAA t where  ( aaa = '210106000000006061'  or aaa = 
'320106000000006062' ) and (  bbb between '20170604145900' and '20170604154100' 
 and ( ccc = '2017-06-04' ))  ) T1
 GROUP BY HHH, ttt) T2
 GROUP BY HHH
 HAVING COUNT(*) >= 8) T3
 WHERE T0.HHH = T3.HHH);

I try to "explain this SQL" to get the execution plan, but it report the same 
error, and then can not get the execution plan.
I also try to "set optimizer=off" and retry the SQL sentence, but the same 
error happen, and "show optimizer" the optimizer  is "on" (automatically set 
"on").

  was:
When I execute a specific sql, a serious bug can happen every time. (Hawq 
version is 2.2.0.0)

BUG information:
FATAL: Unexpect internal error (setref.c:298)
DETAIL: AssertImply failed("!(!var->varattno >= 0) || (var->varattno <= 
list_length(colNames) + list_length(rte- >pseudocols)))", File: "setrefs.c", 
Line: 298)
HINT:  Process 239600 will wait for gp_debug_linger=120 seconds before 
termination.
Note that its locks and other resources will not be released  until then.
server closed the connection unexpectedly
        This probably means the server terminated abnormally
         before or while processing the request.
The connection to the server was lost. Attemping reset: Succeeded.

I use GDB to debug, the GDB information is the same every time. The information 
is: 
Loaded symbols for /lib64/libnss_files.so.2
0x00000032dd40eb5c in recv 0 from /lib64/libpthread.so.0
(gdb) b setrefs.c:298
Breakpoint 1 at 0x846063: file setrefs.c, line 298.
(gdb) c 
Continuing.
Breakpoint 1, set_plan_references_output_asserts (glob=0x7fe96fbccab0, 
plan=0x7fe8e930adb8) at setrefs.c:298
298 set ref s .c:没有那个文件或目录.
(gdb) c 1923
Will ignore next 1922 crossings of breakpoint 1. Continuing.
Breakpoint 1, set_plan_references_output_asserts (glob=0x7fe96fbccab0, 
plan=0x7fe869c70340) at setrefs.c:298
298 in setrefs.c
(gdb) p list_length(allVars) 
$1 = 1422
(gdb) p var->varno 
$2 = 65001
(gdb) p list_length(glob->finalrtable) 
$3 = 66515
(gdb) p var->varattno 
$4 = 31
(gdb) p list_length(colNames) 
$5 = 30
(gdb) p list_length(rte->pseudocols) 
$6 = 0

the SQL sentence is long, Occupies the entire screen, total 45 lines. the SQL 
sentence contain "nested select", many "union all", "where", "or", "and", and 
also have "group by" and "having".

I try to "explain this SQL" to get the execution plan, but it report the same 
error, and then can not get the execution plan.
I also try to "set optimizer=off" and retry the SQL sentence, but the same 
error happen, and "show optimizer" the optimizer  is "on" (automatically set 
"on").


> The bug can appear every time when I execute a specific sql:  Unexpect 
> internal error (setref.c:298), server closed the connection unexpectedly
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HAWQ-1494
>                 URL: https://issues.apache.org/jira/browse/HAWQ-1494
>             Project: Apache HAWQ
>          Issue Type: Bug
>          Components: Core
>            Reporter: fangpei
>            Assignee: Radar Lei
>             Fix For: 2.3.0.0-incubating
>
>
> When I execute a specific sql, a serious bug can happen every time. (Hawq 
> version is 2.2.0.0)
> BUG information:
> FATAL: Unexpect internal error (setref.c:298)
> DETAIL: AssertImply failed("!(!var->varattno >= 0) || (var->varattno <= 
> list_length(colNames) + list_length(rte- >pseudocols)))", File: "setrefs.c", 
> Line: 298)
> HINT:  Process 239600 will wait for gp_debug_linger=120 seconds before 
> termination.
> Note that its locks and other resources will not be released  until then.
> server closed the connection unexpectedly
>         This probably means the server terminated abnormally
>          before or while processing the request.
> The connection to the server was lost. Attemping reset: Succeeded.
> I use GDB to debug, the GDB information is the same every time. The 
> information is: 
> Loaded symbols for /lib64/libnss_files.so.2
> 0x00000032dd40eb5c in recv 0 from /lib64/libpthread.so.0
> (gdb) b setrefs.c:298
> Breakpoint 1 at 0x846063: file setrefs.c, line 298.
> (gdb) c 
> Continuing.
> Breakpoint 1, set_plan_references_output_asserts (glob=0x7fe96fbccab0, 
> plan=0x7fe8e930adb8) at setrefs.c:298
> 298 set ref s .c:没有那个文件或目录.
> (gdb) c 1923
> Will ignore next 1922 crossings of breakpoint 1. Continuing.
> Breakpoint 1, set_plan_references_output_asserts (glob=0x7fe96fbccab0, 
> plan=0x7fe869c70340) at setrefs.c:298
> 298 in setrefs.c
> (gdb) p list_length(allVars) 
> $1 = 1422
> (gdb) p var->varno 
> $2 = 65001
> (gdb) p list_length(glob->finalrtable) 
> $3 = 66515
> (gdb) p var->varattno 
> $4 = 31
> (gdb) p list_length(colNames) 
> $5 = 30
> (gdb) p list_length(rte->pseudocols) 
> $6 = 0
> the SQL sentence is just like :
> SELECT *
> FROM (select t.*,1001 as ttt from AAA t where  ( aaa = '320106000000006235'  
> or aaa = '320106000000006236'  or aaa = '320102000000006292'  or aaa = 
> '320106000000006293'  or aaa = '32010600000006393' ) and (  bbb between 
> '20170601065900' and '20170601175100'  and (ccc = '2017-06-01' ))  union all  
> select t.*,1002 as ttt from AAA t where  ( aaa = '320106000000006007'  or aaa 
> = '320106000000006006' ) and (  bbb between '20170601072900' and 
> '20170601210100'  and ( ccc = '2017-06-01' ))  union all  select t.*,1003 as 
> ttt from AAA t where  ( aaa = '320106000000002772' ) and (  bbb between 
> '20170601072900' and '20170601170100'  and ( ccc = '2017-06-01' ))  union all 
>  select t.*,1004 as ttt from AAA t where  (aaa = '320106000000006115'  or aaa 
> = '320106000000006116'  or aaa = '320106000000006318'  or aaa = 
> '320106000000006319' ) and (  bbb between '20170601085900' and 
> '20170601163100' and ( ccc = '2017-06-01' ))  union all  select t.*,1005 as 
> ttt from AAA t where  ( aaa = '320106000000006180' or aaa = 
> '320104000000006385' ) and (  bbb between '20170601205900' and 
> '20170601230100'  and ( ccc = '2017-06-01' )) union all  select t.*,1006 as 
> ttt from AAA t where  ( aaa = '320102000000006423'  or aaa = 
> '320102000000006255'  or aaa = '320106000000006258'  or aaa = 
> '320106000000006259' ) and (  bbb between '20170601215900' and 
> '20170602004900'  and ( ccc = '2017-06-01'  or ccc = '2017-06-02' ))  union 
> all select t.*,1007 as ttt from AAA t where  ( aaa = '320106000000006175' or 
> aaa = '320106000000006004' ) and (  bbb between '20170602074900' and 
> '20170602182100'  and ( ccc = '2017-06-02'  )) union all select t.*,1008 as 
> ttt from AAA t where  ( aaa = '320102000000006648' ) and (  bbb between 
> '20170602132900' and '20170602134600'  and ( ccc = '2017-06-02' ))  union all 
>  select t.*,1009 as ttt from AAA t where  ( aaa = '320106000000002765'  or 
> aaa = '320100000000006282' ) and (  bbb between '20170602142900' and 
> '20170603175100'  and ( ccc = '2017-06-02'  or ccc = '2017-06-03' ))  union 
> all  select t.*,1010 as ttt from AAA t where  (aaa = '320106000000006060' ) 
> and (  bbb between '20170602165900' and '20170603034100'  and ( ccc = 
> '2017-06-02'  or ccc = '2017-06-03' ))  union all select t.*,1011 as ttt from 
> AAA t where  ( aaa = '3201060000000062229'  or aaa = '320106000000006230'  or 
> aaa = '320102000000002783'  or aaa = '320102000000006304' ) and (  bbb 
> between '20170603192900' and '20170604183100'  and ( ccc = '2017-06-03'  or 
> ccc = '2017-06-04' ))  union all select t.*,1012 as ttt from AAA t where  ( 
> aaa = '320113000000006549' ) and (  bbb between '20170604071947' and 
> '20170604220100'  and ( ccc = '2017-06-04' ))  union all select t.*1013 as 
> ttt from AAA t where  ( aaa = '320106000000006061'  or aaa = 
> '320106000000006062' ) and (  bbb between '20170604145900' and 
> '20170604154100'  and ( ccc = '2017-06-04' ))  ) T0 
> WHERE EXISTS (SELECT HHH
>   FROM (SELECT HHH, COUNT(*)
>   FROM (SELECT HHH, ttt, COUNT(*)
>   FROM (select t.*,1001 as ttt from AAA t where  ( aaa = '320106000000006235' 
>  or aaa = '320106000000006236'  or aaa = '320102000000006292'  or aaa = 
> '320106000000006293'  or aaa = '320106000000006393' ) and (  bbb between 
> '20170601065900' and '20170601175100'  and ( ccc = '2017-06-01' ))  union all 
>  select t.*,1002 as ttt from AAA t where  ( aaa = '320106000000006007'  or 
> aaa = '320106000000006006' ) and (  bbb between '20170601072900' and 
> '20170601170100'  and ( ccc = '2017-06-01' ))  union all  select t.*,1003 as 
> ttt from AAA t where  ( aaa = '320106000000002772' ) and ( bbb between 
> '20170601072900' and '20170601170100'  and ( ccc = '2017-06-01' ))  union all 
>  select t.*,1004 as ttt from AAA t where  (aaa = '320106000000006115'  or aaa 
> = '320106000000006116'  or aaa = '320106000000006318'  or aaa = 
> '320106000000006319' ) and (  bbb between '20170601085900' and 
> '20170601163100'  and ( ccc = '2017-06-01' ))  union all select t.*,1005 as 
> ttt from AAA t where  ( aaa = '320106000000006180'  or aaa = 
> '320104000000006385' ) and (  bbb between '20170601205900' and 
> '20170601230100'  and ( ccc = '2017-06-01' ))  union all  select t.*,1006 as 
> ttt from AAA t where  ( aaa = '320102000000006423'  or aaa = 
> '320102000000006255'  or aaa = '320106000000006258'  or aaa = 
> '320106000000006259' ) and (  bbb between '20170601215900' and 
> '20170602004900'  and ( ccc = '2017-06-01'  or ccc = '2017-06-02' ))  union 
> all  select t.*,1007 as ttt from AAA t where  ( aaa = '320106000000006175'  
> or aaa = '320106000000006004' ) and (  bbb between '20170602074900' and 
> '20170602182100'  and ( ccc = '2017-06-02' ))  union all select t.*,1008 as 
> ttt from AAA t where  ( aaa = '320102000000006648' ) and (  bbb between 
> '20170602132900' and '20170602134600'  and ( ccc = '2017-06-02' ))  union all 
>  select t.*,1009 as ttt from AAA t where  ( aaa = '320106000000002765'  or 
> aaa = '320100000000006282' ) and (  bbb between '20170602142900' and 
> '20170603175100'  and ( ccc = '2017-06-02'  or ccc = '2017-06-03' ))  union 
> all select t.*,1010 as ttt from AAA t where  ( aaa = '320106000000006060' ) 
> and (  bbb between '20170602165900' and '20170603034100'  and ( ccc = 
> '2017-06-02'  or ccc = '2017-06-03' ))  union all select t.*,1011 as ttt from 
> AAA t where  ( aaa = '320106000000006229'  or aaa = '320106000000006230'  or 
> aaa = '320102000000002783'  or aaa = '320102000000006304' ) and (  bbb 
> between '20170603192900' and '20170604183100'  and ( ccc = '2017-06-03'  or 
> ccc = '2017-06-04' ))  union all  select t.*,1012 as ttt from AAA t where  ( 
> aaa = '32011300000000549' ) and (  bbb between '20170604071947' and 
> '20170604220100'  and ( ccc = '2017-06-04' ))  union all select t.*,1013 as 
> ttt from AAA t where  ( aaa = '210106000000006061'  or aaa = 
> '320106000000006062' ) and (  bbb between '20170604145900' and 
> '20170604154100'  and ( ccc = '2017-06-04' ))  ) T1
>  GROUP BY HHH, ttt) T2
>  GROUP BY HHH
>  HAVING COUNT(*) >= 8) T3
>  WHERE T0.HHH = T3.HHH);
> I try to "explain this SQL" to get the execution plan, but it report the same 
> error, and then can not get the execution plan.
> I also try to "set optimizer=off" and retry the SQL sentence, but the same 
> error happen, and "show optimizer" the optimizer  is "on" (automatically set 
> "on").



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to