3.1.7 执行sql报错 ERROR 1064 (HY000): Unknown error

版本:3.1.7
执行sql直接报错ERROR 1064 (HY000): Unknown error
sql:

set @update_start = date_sub(current_date, 1), @update_end = date_sub(current_date, 0)
;

select *
from
(
    select
      line_sales_bill_no
    from
      aly_edw_dws_sales.dws_sales_line_sales_bill_di a
    where
      (a.updated_time >= @update_start and a.updated_time < @update_end)
      or
      a.customer_id in (
        select
          customer_id
        from
          aly_edw_dim_pub.dim_pub_oc_dealer_zip_di
        where
          is_latest = 1
          and
            (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.product_id in (
        select
          product_id
        from
          aly_edw_dim_pub.dim_pub_oc_product_df
        where
          (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.character_id in (
        select
          character_id
        from
          aly_edw_dim_pub.dim_pub_oc_character_df
        where
          (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.corporation_id in (
        select
          office_id
        from
          aly_edw_dim_pub.dim_pub_oc_office_zip_di
        where
          is_latest = 1
          and
          (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.factory_id in (
        select
          office_id
        from
          aly_edw_dim_pub.dim_pub_oc_office_zip_di
        where
          is_latest = 1
          and
          (updated_time >= @update_start and updated_time < @update_end)
      )
) t;

fe.warn.log信息:

java.util.NoSuchElementException: null
        at java.util.ArrayList$Itr.next(ArrayList.java:1000) ~[?:?]
        at com.google.common.collect.Ordering.min(Ordering.java:568) ~[spark-dpp-1.0.0.jar:?]
        at com.google.common.collect.Ordering.min(Ordering.java:593) ~[spark-dpp-1.0.0.jar:?]
        at com.starrocks.sql.optimizer.rule.join.JoinReorderDP.getBestExpr(JoinReorderDP.java:101) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.rule.join.JoinReorderDP.enumerate(JoinReorderDP.java:48) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.rule.join.JoinOrder.reorder(JoinOrder.java:226) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.rule.join.ReorderJoinRule.enumerate(ReorderJoinRule.java:95) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.rule.join.ReorderJoinRule.transform(ReorderJoinRule.java:230) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.Optimizer.memoOptimize(Optimizer.java:551) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.Optimizer.optimizeByCost(Optimizer.java:201) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.optimizer.Optimizer.optimize(Optimizer.java:134) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.StatementPlanner.createQueryPlanWithReTry(StatementPlanner.java:203) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.StatementPlanner.planQuery(StatementPlanner.java:123) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.StatementPlanner.plan(StatementPlanner.java:92) ~[starrocks-fe.jar:?]
        at com.starrocks.sql.StatementPlanner.plan(StatementPlanner.java:61) ~[starrocks-fe.jar:?]
        at com.starrocks.qe.StmtExecutor.execute(StmtExecutor.java:456) ~[starrocks-fe.jar:?]
        at com.starrocks.qe.ConnectProcessor.handleQuery(ConnectProcessor.java:366) ~[starrocks-fe.jar:?]
        at com.starrocks.qe.ConnectProcessor.dispatch(ConnectProcessor.java:480) ~[starrocks-fe.jar:?]
        at com.starrocks.qe.ConnectProcessor.processOnce(ConnectProcessor.java:756) ~[starrocks-fe.jar:?]
        at com.starrocks.mysql.nio.ReadListener.lambda$handleEvent$0(ReadListener.java:69) ~[starrocks-fe.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at java.lang.Thread.run(Thread.java:834) ~[?:?]

奇怪的是,随便去掉一个or就能出结果或正常执行

发一下 去掉任意一个or能执行出来,和完整sql 执行报错 的 explain costs +sql 的结果

完整sql explain costs也报错
image

去掉的explain costs
explain_costs.txt (265.8 KB)

去掉对应的sql也发一下

去掉的sql就是最下面的or删了
删除的部分:

or
      a.factory_id in (
        select
          office_id
        from
          aly_edw_dim_pub.dim_pub_oc_office_zip_di
        where
          is_latest = 1
          and
          (updated_time >= @update_start and updated_time < @update_end)
      )

去掉的sql:

set @update_start = date_sub(current_date, 1), @update_end = date_sub(current_date, 0)
;

select *
from
(
    select
      line_sales_bill_no
    from
      aly_edw_dws_sales.dws_sales_line_sales_bill_di a
    where
      (a.updated_time >= @update_start and a.updated_time < @update_end)
      or
      a.customer_id in (
        select
          customer_id
        from
          aly_edw_dim_pub.dim_pub_oc_dealer_zip_di
        where
          is_latest = 1
          and
            (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.product_id in (
        select
          product_id
        from
          aly_edw_dim_pub.dim_pub_oc_product_df
        where
          (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.character_id in (
        select
          character_id
        from
          aly_edw_dim_pub.dim_pub_oc_character_df
        where
          (updated_time >= @update_start and updated_time < @update_end)
      )
      or
      a.corporation_id in (
        select
          office_id
        from
          aly_edw_dim_pub.dim_pub_oc_office_zip_di
        where
          is_latest = 1
          and
          (updated_time >= @update_start and updated_time < @update_end)
      )
) t;

拿一下去掉最后一个or和不去掉or 两个sql的query dump

wget --user=root --password=1234 --post-file 1.sql http://fe_host:fe_http_port/api/query_dump?db=xxx -O dump_file

user 和 password 是执行sql 的用户名以及密码,
post_file为包含查询sql的文件,把sql放到一个文件中,该文件命名为1.sql
db 为该sql查询的db
dump_file是返回的数据(最后需要发dump_file文件 )

去掉or的dump file:
dump_file_delor (9.1 KB)

完整sql的dump file:
dump_file_delor (9.1 KB)

:joy: 不知道是不是因为两个文件里的内容是一样的,第二个文件上传后直接重命名了…
image

sql文件中只写 select部分的sql,现在打出来的 query dump 是set @update_start = date_sub(current_date, 1), @update_end = date_sub(current_date, 0); 的,需要带select部分sql的querydump文件

完全sql的dump file:
dump_file_all (2) (26.2 KB)

去掉or的dump file:
dump_file_delor (2) (47.5 KB)

你好 麻烦set cross_join_cost_penalty = 20 后再执行下原始的sql?

还是报相同的错误 :sob:
image
image

好的, 我们确认下问题

1赞

这个问题有后续吗?我们也遇到相同的问题了。版本是3.3.3,执行sql,starrocks重启后第一次可以正常执行,后续再执行就报上面的错误。需要再次重启starrocks后才能正常