Shannon-Data / ShannonBase

A MySQL HTAP Database, Open Source version of MySQL Heatwave, Powered by AI.
https://www.shannonbase.org
Other
16 stars 6 forks source link

bug: dead lock when execute queries #171

Closed ShannonBase closed 6 months ago

ShannonBase commented 6 months ago

Search before asking

Version

ver0.2.0-beta

What's Wrong?

session 1: alter table tt secondary_load;

session2 : insert into tt values(xxxx); batch insertion.

then in session 1: execute select statement, a dead lock occurs.

when pop the changes into rapid, and now, executing some queries on rapid. it could occur deadlock.

How to Reproduce?

1: session1: CALL insert_into_tt1(); //trying to insert 1000rows into a table.

2: session2: select count(1) from tt1;

Are you willing to submit PR?

RingsC commented 6 months ago

It's not a deadlock. the root cause is here: need to imp the records function to get the real rows count of a rapid table. and optimization does not work rightly.

  /*
     Try to optimize count(*), min() and max() to const fields if
     there is implicit grouping (aggregate functions but no
     group_list). In this case, the result set shall only contain one
     row.
  */
  if (tables_list && implicit_grouping &&
      !(query_block->active_options() & OPTION_NO_CONST_TABLES)) {
    aggregate_evaluated outcome;
    if (optimize_aggregated_query(thd, query_block, *fields, where_cond,
                                  &outcome)) {

!(query_block->active_options() & OPTION_NO_CONST_TABLES) return false. and in ShannonPrepareSecondaryEngine, it set to OPTION_NO_CONST_TABLES