Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: The tianmu_ini_allowmysqlQuerypath parameter causes the Tianmu engine to crash #477

Closed
1 task done
adofsauron opened this issue Sep 8, 2022 · 10 comments
Closed
1 task done
Assignees
Labels
A-bug Something isn't working

Comments

@adofsauron
Copy link
Collaborator

adofsauron commented Sep 8, 2022

Describe the problem

StoneDB does not support functions that contain dynamic SQL. In order to avoid errors, we changed the parameter tianmu_ini_allowmysqlQuerypath. After the SQL is executed, a warning will be displayed.

image

mysql> show warnings;
+-------+------+-------------------------------------------------------------------+
| Level | Code | Message                                                           |
+-------+------+-------------------------------------------------------------------+
| Note  | 1105 | Query syntax not implemented in Tianmu, executed by MySQL engine. |
+-------+------+-------------------------------------------------------------------+
1 row in set (0.00 sec)

According to the warning msg, the SQL syntax cannot be implemented in the Tianmu engine. This warning is caused by the parameter setting. If you run the following command, StoneDB will crash.

image

Expected behavior

No response

How To Reproduce

No response

Environment

No response

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@adofsauron adofsauron added the A-bug Something isn't working label Sep 8, 2022
@adofsauron adofsauron self-assigned this Sep 8, 2022
@adofsauron
Copy link
Collaborator Author

Requirements:

  1. Support dynamic function call in column storage engine

  2. Use custom dynamic function function query statement, query performance approximates SQL rewritten statement (millisecond level)

@adofsauron
Copy link
Collaborator Author

adofsauron commented Sep 9, 2022

Existing code supports evaluation:

  1. User-defined functions are not supported

  2. The tianmu_ini_allowmysqlQuerypath parameter must be enabled to use the custom function, but a large number of SQL query results are incorrect after it is enabled

Development Impact Assessment:

Whether to develop custom functions in the column storage engine

  1. If tianmu_ini_allowmysqlQuerypath parameter is used, after locating, the code scope that needs to be involved is too large, how to handle

2.1 Does anyone know the impact of tianmu_ini_allowmysqlQuerypath parameter on code logic?

2.2 If no one does, how many man-months will it take to understand the logic?

2.3 Even if the logic of the impact is clearly understood, what should I do if the amount of code involved in the modification is huge and cannot be quickly completed within a day or two?

2.4 Even if the enhanced version of overtime, every day to get the morning Lingling day, but the brain hormone secretion depletion toxin continues to poison the advancement of logic, how to proceed?

@adofsauron
Copy link
Collaborator Author

adofsauron commented Sep 9, 2022

mysql> SELECT C.SUSID,
    ->        C2.CORPNAME AS SCORPNAME,
    ->        C2.BNAME,
    ->        C.USID,
    ->        C.CORPNAME,
    ->        C.IBUSINESSID,
    ->        C.TTLB
    ->   FROM (SELECT USID,
    ->                CORPNAME,
    ->                IBUSINESSID,
    ->                TTLB,
    ->                FIND_TOP_USID(USID) AS SUSID
    ->           FROM CUSTOM
    ->          WHERE LGTP = '02'
    ->            AND USTP = '01'
    ->            AND IBUSINESSID = 2) C
    ->   LEFT JOIN CUSTOM C2
    ->     ON C2.USID = C.SUSID;
ERROR 6 (HY000): The query includes syntax that is not supported by the storage engine. Either restructure the query with supported syntax, or enable the MySQL core::Query Path in config file to execute the query with reduced performance.

@adofsauron
Copy link
Collaborator Author

#!/bin/bash

index=0
while [[ true ]]; do
    value="VALUE FOR $index"

    echo /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e "
        SELECT FIND_TOP_USID(C.USID) AS SUSID,
            C2.CORPNAME AS SCORPNAME,
            C2.BNAME,
            C.USID,
            C.CORPNAME,
            C.IBUSINESSID,
            C.TTLB
        FROM CUSTOM C
        LEFT JOIN CUSTOM C2
            ON C2.USID = C.SUSID
        WHERE C.LGTP = '02'
        AND C.USTP = '01'
        AND C.IBUSINESSID = 2;
    " 
    
    /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e "
        SELECT FIND_TOP_USID(C.USID) AS SUSID,
            C2.CORPNAME AS SCORPNAME,
            C2.BNAME,
            C.USID,
            C.CORPNAME,
            C.IBUSINESSID,
            C.TTLB
        FROM CUSTOM C
        LEFT JOIN CUSTOM C2
            ON C2.USID = C.SUSID
        WHERE C.LGTP = '02'
        AND C.USTP = '01'
        AND C.IBUSINESSID = 2;
    " 

    sleep 1s

    /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " show warnings; "

    /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " show tables; "

    let index++  

    if [[ 100 == $index ]]; then
        break
    fi

    sleep 1s

    echo "index: $index over"

done

@adofsauron
Copy link
Collaborator Author

/stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e 
        SELECT FIND_TOP_USID(C.USID) AS SUSID,
            C2.CORPNAME AS SCORPNAME,
            C2.BNAME,
            C.USID,
            C.CORPNAME,
            C.IBUSINESSID,
            C.TTLB
        FROM CUSTOM C
        LEFT JOIN CUSTOM C2
            ON C2.USID = C.SUSID
        WHERE C.LGTP = '02'
        AND C.USTP = '01'
        AND C.IBUSINESSID = 2;
    
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------+-----------+-------+----------------+--------------------------------------------------------------------------------+-------------+------+
| SUSID          | SCORPNAME | BNAME | USID           | CORPNAME                                                                       | IBUSINESSID | TTLB |
+----------------+-----------+-------+----------------+--------------------------------------------------------------------------------+-------------+------+
| ARTIZAN        | NULL      | NULL  | ARTIZAN        | 上海佳华国际旅行社有限公司                                                     |           2 | 01   |
| chuntian123456 | NULL      | NULL  | chuntian123456 | 江苏春天国际旅行社有限公司                                                     |           2 | 01   |
| CITS202020     | NULL      | NULL  | CITS202020     | 中国国旅(浙江)国际旅行社有限公司                                             |           2 | 01   |
| CODEUSER       | NULL      | NULL  | CODEUSER       | 扫码购                                                                         |           2 | 01   |
| cytcyt         | NULL      | NULL  | cytcyt         | 中景旅游网                                                                     |           2 | 99   |
| cyttest        | NULL      | NULL  | cyttest        | 测试                                                                           |           2 | 99   |
| cytToTdosfxs   | NULL      | NULL  | cytToTdosfxs   | 中景旅游                                                                       |           2 | 99   |
| dcmeituan      | NULL      | NULL  | dcmeituan      | 美团网                                                                         |           2 | 99   |
| ecgrup         | NULL      | NULL  | ecgrup         | 深圳市鼎游开发测试                                                             |           2 | 01   |
| feizhu         | NULL      | NULL  | feizhu         | 1                                                                              |           2 | 99   |
| jxht           | NULL      | NULL  | jxht           | 嘉兴海棠旅游有限公司                                                           |           2 | 01   |
| jyclhx         | NULL      | NULL  | jyclhx         | 长乐鸿禧酒店                                                                   |           2 | 99   |
| jyclkz         | NULL      | NULL  | jyclkz         | 长乐客栈                                                                       |           2 | 99   |
| jycqgj         | NULL      | NULL  | jycqgj         | 长青国际酒店                                                                   |           2 | 99   |
| jyctrip        | NULL      | NULL  | jyctrip        | 携程网                                                                         |           2 | 99   |
| jydyh          | NULL      | NULL  | jydyh          | 古运河                                                                         |           2 | 99   |
| jydytg         | NULL      | NULL  | jydytg         |                                                                                |           2 | 99   |
| jyessq         | NULL      | NULL  | jyessq         | 二十四桥酒店                                                                   |           2 | 99   |
| jyfhly         | NULL      | NULL  | jyfhly         |                                                                                |           2 | 99   |
| jyfskh         | NULL      | NULL  | jyfskh         | 佛山康辉旅行社                                                                 |           2 | 99   |
| jygey          | NULL      | NULL  | jygey          | 个园                                                                           |           2 | 99   |
| jyhey          | NULL      | NULL  | jyhey          | 何园                                                                           |           2 | 99   |
| jyhgjr         | NULL      | NULL  | jyhgjr         | 扬州皇冠假日酒店                                                               |           2 | 99   |
| jyhmdks        | NULL      | NULL  | jyhmdks        | 扬州华美达凯莎广场酒店                                                         |           2 | 99   |
| jyhqf          | NULL      | NULL  | jyhqf          | 虹桥坊                                                                         |           2 | 99   |
| jyhqfjd        | NULL      | NULL  | jyhqfjd        | 虹桥坊酒店                                                                     |           2 | 99   |
| jyhygj         | NULL      | NULL  | jyhygj         | 扬州花园国际大酒店有限公司                                                     |           2 | 99   |
| jyhzl          | NULL      | NULL  | jyhzl          |                                                                                |           2 | 99   |
| jyhzyd         | NULL      | NULL  | jyhzyd         | 杭州远大                                                                       |           2 | 99   |
| jyjldjd        | NULL      | NULL  | jyjldjd        | 扬州金陵大饭店                                                                 |           2 | 99   |
| jyjsmljd       | NULL      | NULL  | jyjsmljd       | 江苏福满楼酒店管理有限公司(扬州文昌阁智选假日酒店)                           |           2 | 99   |
| jyjtjd         | NULL      | NULL  | jyjtjd         | 君亭酒店                                                                       |           2 | 99   |
| jyjyxzgy       | NULL      | NULL  | jyjyxzgy       | 扬州中集菁英行政公寓                                                           |           2 | 99   |
| jyldfpjd       | NULL      | NULL  | jyldfpjd       |                                                                                |           2 | 99   |
| jyldfu         | NULL      | NULL  | jyldfu         | 扬州绿地福朋喜来登酒店                                                         |           2 | 99   |
| jylvmama       | NULL      | NULL  | jylvmama       | 驴妈妈网                                                                       |           2 | 99   |
| jylxs          | NULL      | NULL  | jylxs          |                                                                                |           2 | 99   |
| jyscdj         | NULL      | NULL  | jyscdj         | 瘦西湖宋城度假酒店                                                             |           2 | 99   |
| jysedyl        | NULL      | NULL  | jysedyl        | 扬州三盛希尔顿逸林酒店                                                         |           2 | 99   |
| jyshzh         | NULL      | NULL  | jyshzh         | 上海甄荟网络科技有限公司(自我游)                                             |           2 | 99   |
| jysxhkj        | NULL      | NULL  | jysxhkj        | 瘦西湖科技                                                                     |           2 | 99   |
| jysxhwq        | NULL      | NULL  | jysxhwq        | 瘦西湖温泉                                                                     |           2 | 99   |
| jysxhwqdj      | NULL      | NULL  | jysxhwqdj      | 隐居瘦西湖温泉度假酒店                                                         |           2 | 99   |
| jysxhxcx       | NULL      | NULL  | jysxhxcx       | 瘦西湖小程序                                                                   |           2 | 99   |
| jysxhzfb       | NULL      | NULL  | jysxhzfb       | 瘦西湖支付宝小程序                                                             |           2 | 99   |
| jytcwl         | NULL      | NULL  | jytcwl         | 同程文旅                                                                       |           2 | 99   |
| jytest         | NULL      | NULL  | jytest         |                                                                                |           2 | 99   |
| jytongcheng    | NULL      | NULL  | jytongcheng    | 同程网                                                                         |           2 | 99   |
| jywl           | NULL      | NULL  | jywl           | 123微旅                                                                        |           2 | 99   |
| jywqdjc        | NULL      | NULL  | jywqdjc        | 温泉度假村                                                                     |           2 | 99   |
| jywts1688      | NULL      | NULL  | jywts1688      | 江阴市职工旅行社有限公司                                                       |           2 | 01   |
| jyxedhp        | NULL      | NULL  | jyxedhp        | 扬州东高铁站希尔顿欢朋酒店                                                     |           2 | 99   |
| jyxgll         | NULL      | NULL  | jyxgll         | 扬州香格里拉                                                                   |           2 | 99   |
| jyxpjd         | NULL      | NULL  | jyxpjd         | 扬州希朋酒店管理有限公司                                                       |           2 | 99   |
| jyxxqg         | NULL      | NULL  | jyxxqg         | 学习强国分销                                                                   |           2 | 99   |
| jyybg          | NULL      | NULL  | jyybg          | 迎宾馆                                                                         |           2 | 99   |
| jyybgh         | NULL      | NULL  | jyybgh         | 迎宾馆                                                                         |           2 | 99   |
| jyyjjd         | NULL      | NULL  | jyyjjd         | 隐居酒店                                                                       |           2 | 99   |
| jyypjj         | NULL      | NULL  | jyypjj         | 扬鹏锦江酒店                                                                   |           2 | 99   |
| jyyxb          | NULL      | NULL  | jyyxb          |                                                                                |           2 | 99   |
| jyyxx          | NULL      | NULL  | jyyxx          |                                                                                |           2 | 99   |
| jyyyzz         | NULL      | NULL  | jyyyzz         | 友谊智助                                                                       |           2 | 99   |
| jyyzjxed       | NULL      | NULL  | jyyzjxed       | 扬州扬子江希尔顿欢朋酒店                                                       |           2 | 99   |
| jyyzwcl        | NULL      | NULL  | jyyzwcl        | 扬州望潮楼大酒店有限公司                                                       |           2 | 99   |
| jyyzyxyhyjd    | NULL      | NULL  | jyyzyxyhyjd    | 扬州国医书院合怡酒店                                                           |           2 | 99   |
| jyzf           | NULL      | NULL  | jyzf           | 郑峰                                                                           |           2 | 99   |
| jyzxtc         | NULL      | NULL  | jyzxtc         | 扬州中兴天成国际酒店                                                           |           2 | 99   |
| jyzyw          | NULL      | NULL  | jyzyw          | 茱萸湾                                                                         |           2 | 99   |
| nodout         | NULL      | NULL  | nodout         | 慧敏旅行社服务(上海)有限公司                                                 |           2 | 01   |
| rzpagl123      | NULL      | NULL  | rzpagl123      | 日照平安国际旅行社有限公司                                                     |           2 | 01   |
| SSTDZH         | NULL      | NULL  | SSTDZH         | 赛思科技                                                                       |           2 | 01   |
| SYGL           | NULL      | NULL  | SYGL           | 江苏世友国际旅行社有限公司                                                     |           2 | 01   |
| szcyts0512     | NULL      | NULL  | szcyts0512     | 苏州青年旅行社股份有限公司                                                     |           2 | 01   |
| taobao         | NULL      | NULL  | taobao         | 淘宝                                                                           |           2 | 99   |
| wh1715         | NULL      | NULL  | wh1715         | 五湖国际旅行社(苏州)有限公司                                                 |           2 | 01   |
| whoami1        | NULL      | NULL  | whoami1        | whoami                                                                         |           2 | 01   |
| yinhongji2     | NULL      | NULL  | yinhongji2     | test                                                                           |           2 | 01   |
| ylyzsxh        | NULL      | NULL  | ylyzsxh        |                                                                                |           2 | 99   |
| yztrdjd        | NULL      | NULL  | yztrdjd        | 扬州泰润大酒店                                                                 |           2 | 99   |
| yzwdyhjd       | NULL      | NULL  | yzwdyhjd       | 扬州万达颐华酒店                                                               |           2 | 99   |
| yzzjglytdjd    | NULL      | NULL  | yzzjglytdjd    | 扬州中集格兰云天大酒店                                                         |           2 | 99   |
| ZLGJ           | NULL      | NULL  | ZLGJ           | 中旅国际                                                                       |           2 | 01   |
+----------------+-----------+-------+----------------+--------------------------------------------------------------------------------+-------------+------+
/stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e  show warnings; 
mysql: [Warning] Using a password on the command line interface can be insecure.
/stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e  show tables; 
mysql: [Warning] Using a password on the command line interface can be insecure.
+-------------------------------+
| Tables_in_dingyou             |
+-------------------------------+
| CUSTOM                        |
| EDMCROWDKINDPRICETAB          |
| EDMTICKETTYPETAB              |
| STSSALESSETTLEMENTTAB         |
| STSSALESSETTLEMENTTABLIST     |
| STSSALESVOUCHERDETAILSTAB     |
| STSSALESVOUCHERDETAILSTABLIST |
| STSSALESVOUCHERTAB            |
| STSSALESVOUCHERTABLIST        |
| STSSOLDTICKETTAB              |
| TICKETCHECKLIST               |
| jrk_all_bak                   |
| t1                            |
+-------------------------------+
index: 9999 over
You have new mail in /var/spool/mail/root


@adofsauron
Copy link
Collaborator Author

Using the Release version, open LOG_BIN_TRUST_FUNCTION_CREATORS =1, execute the manually rewritten statement calling the custom dynamic function, then execute Show tables, and an accidental Crash occurs

Problem Description:

Compile using Relase version

Open the tianmu_ini_allowmysqlquerypath = 1

Open the log_bin_trust_function_creators = 1

Execute the overwritten statement

The mysqld process crashed accidentally. Procedure

@adofsauron
Copy link
Collaborator Author

The stack that crashed:

(gdb) bt
#0 belongs_to_p_s (tl=0x7f84d401c490, tl=0x7f84d401c490) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/table.h:3056
#1 close_thread_tables (thd=thd@entry=0x7f84d4002c10) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_base.cc:1667
#2 0x0000000000ebb8ac in mysql_execute_command (thd=thd@entry=0x7f84d4002c10, first_level=first_level@entry=true)
at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:5032
#3 0x0000000000ec1ee5 in mysql_parse (thd=thd@entry=0x7f84d4002c10, parser_state=parser_state@entry=0x7f88ab7d5fe0)
at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:5621
#4 0x0000000000ec29e4 in dispatch_command (thd=thd@entry=0x7f84d4002c10, com_data=com_data@entry=0x7f88ab7d6640, command=COM_QUERY)
at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:1495
#5 0x0000000000ec4430 in do_command (thd=thd@entry=0x7f84d4002c10) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/sql_parse.cc:1034
#6 0x0000000000f85250 in handle_connection (arg=arg@entry=0x5605220) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/sql/conn_handler/connection_handler_per_thread.cc:313
#7 0x000000000144f204 in pfs_spawn_thread (arg=0x623ff10) at /data2/jenkins/workspace/stonedb5.7-zsl-centos7.9-30-238/storage/perfschema/pfs.cc:2197
#8 0x00007f88f6784ea5 in start_thread (arg=0x7f88ab7d7700) at pthread_create.c:307
#9 0x00007f88f3ccdb0d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
/**
Check if the table belongs to the P_S, excluding setup and threads tables.
@note Performance Schema tables must be accessible independently of the
LOCK TABLE mode. This function is needed to handle the special case
of P_S tables being used under LOCK TABLE mode.
*/
inline bool belongs_to_p_s(TABLE_LIST *tl)
{
return (!strcmp("performance_schema", tl->db) &&
strcmp(tl->table_name, "threads") &&
strstr(tl->table_name, "setup_") == NULL);
}
(gdb) p tl->db
$1 = 0x0
(gdb) p *tl
$3 = {next_local = 0x0, next_global = 0x0, prev_global = 0x0, db = 0x0, table_name = 0x0, alias = 0x0, target_tablespace_name = {str = 0x0, length = 0}, schema_table_name = 0x0,
option = 0x0, opt_hints_table = 0x0, opt_hints_qb = 0x0, m_tableno = 0, m_map = 0, m_join_cond = 0x0, m_sj_cond = 0x0, sj_inner_tables = 0, natural_join = 0x0, is_natural_join = false,
join_using_fields = 0x0, join_columns = 0x0, is_join_columns_complete = false, next_name_resolution_table = 0x0, index_hints = 0x0, table = 0x0, table_id = {
static TABLE_ID_MAX = 281474976710655, m_id = 0}, derived_result = 0x0, correspondent_table = 0x0, derived = 0x0, schema_table = 0x0, schema_select_lex = 0x0,
schema_table_reformed = false, schema_table_param = 0x0, select_lex = 0x0, view = 0x0, field_translation = 0x0, field_translation_end = 0x0, merge_underlying_list = 0x0,
view_tables = 0x0, belong_to_view = 0x0, referencing_view = 0x0, parent_l = 0x0, security_ctx = 0x0, view_sctx = 0x0, allowed_show = false, next_leaf = 0x0, derived_where_cond = 0x0,
check_option = 0x0, replace_filter = 0x0, select_stmt = {str = 0x0, length = 0}, md5 = {str = 0x0, length = 0}, source = {str = 0x0, length = 0}, view_db = {str = 0x0, length = 0},
view_name = {str = 0x0, length = 0}, timestamp = {str = 0x0, length = 0}, definer = {user = {str = 0x0, length = 0}, host = {str = 0x0, length = 0}, plugin = {str = 0x0, length = 0},
auth = {str = 0x0, length = 0}, uses_identified_by_clause = false, uses_identified_with_clause = false, uses_authentication_string_clause = false,
uses_identified_by_password_clause = false, alter_status = {update_password_expired_fields = false, update_password_expired_column = false, use_default_password_lifetime = false,
expire_after_days = 0, update_account_locked_column = false, account_locked = false}}, file_version = 0, updatable_view = 0, algorithm = 0, view_suid = 2, with_check = 0,
effective_algorithm = VIEW_ALGORITHM_UNDEFINED, grant = {grant_table = 0x3, version = 16908288, privilege = 0, m_internal = {m_schema_lookup_done = false, m_schema_access = 0x0,
m_table_lookup_done = false, m_table_access = 0x0}}, engine_data = 11, callback_func = 0x7f84d4b1c6a0, lock_type = -738130240, outer_join = 32644, shared = 0, db_length = 32,
table_name_length = 992, m_updatable = 8, m_insertable = false, straight = false, updating = false, force_index = false, ignore_leaves = false, dep_tables = 0, on_expr_dep_tables = 12664,
nested_join = 0x61c2000, embedding = 0xe5d2a0 <sql_alloc_error_handler()>, join_list = 0x7f8800000064, cacheable_table = false, table_in_first_from_clause = false,
open_type = OT_TEMPORARY_OR_BASE, contain_auto_increment = false, check_option_processed = false, replace_filter_processed = false, required_type = FRMTYPE_ERROR,
timestamp_buffer = "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000", prelocking_placeholder = false, open_strategy = TABLE_LIST::OPEN_NORMAL,
internal_tmp_table = false, is_alias = false, is_fqtn = false, view_creation_ctx = 0x0, view_client_cs_name = {str = 0x0, length = 0}, view_connection_cl_name = {str = 0x0, length = 0},
view_body_utf8 = {str = 0x0, length = 0}, derived_key_list = {<base_list> = {<Sql_alloc> = {}, first = 0x0, last = 0x0, elements = 0}, },
trg_event_map = 0 '\000', i_s_requested_object = 0, has_db_lookup_value = false, has_table_lookup_value = false, table_open_method = 0, schema_table_state = NOT_PROCESSED, mdl_request = {
type = MDL_INTENTION_EXCLUSIVE, duration = MDL_STATEMENT, next_in_list = 0x0, prev_in_list = 0x0, ticket = 0x0, key = {m_length = 0, m_db_name_length = 0,
m_ptr = '\000' <repeats 28 times>, "\350`\000Ԅ\177\000\000\340\375<\006\000\000\000\000\020\277\001Ԅ\177\000\000\000\000\000\000\000\000\000\000\001", '\000' <repeats 143 times>...,
static m_namespace_to_wait_state_name = {{m_key = 111, m_name = 0x19235dd "Waiting for global read lock", m_flags = 0}, {m_key = 112,
m_name = 0x19236a0 "Waiting for tablespace metadata lock", m_flags = 0}, {m_key = 113, m_name = 0x19236c8 "Waiting for schema metadata lock", m_flags = 0}, {m_key = 114,
m_name = 0x19236f0 "Waiting for table metadata lock", m_flags = 0}, {m_key = 115, m_name = 0x1923710 "Waiting for stored function metadata lock", m_flags = 0}, {m_key = 116,
m_name = 0x1923740 "Waiting for stored procedure metadata lock", m_flags = 0}, {m_key = 117, m_name = 0x1923770 "Waiting for trigger metadata lock", m_flags = 0}, {m_key = 118,
m_name = 0x1923798 "Waiting for event metadata lock", m_flags = 0}, {m_key = 119, m_name = 0x19235fa "Waiting for commit lock", m_flags = 0}, {m_key = 120,
m_name = 0x1923612 "User lock", m_flags = 0}, {m_key = 121, m_name = 0x19237b8 "Waiting for locking service lock", m_flags = 0}}}, m_src_file = 0x0, m_src_line = 0},
view_no_explain = false, partition_names = 0x0, m_join_cond_optim = 0x0, cond_equal = 0x0, optimized_away = 96, derived_keys_ready = 204, m_table_ref_type = 32644,
m_table_ref_version = 140208469251952}

@adofsauron
Copy link
Collaborator Author

Problem solving:

In the belongs_to_p_s function, if DB and table_name are not in TABLE_LISTS, the decision is considered a failure

The function logic

/**
Check if the table belongs to the P_S, excluding setup and threads tables.
@note Performance Schema tables must be accessible independently of the
LOCK TABLE mode. This function is needed to handle the special case
of P_S tables being used under LOCK TABLE mode.
*/
inline bool belongs_to_p_s(TABLE_LIST *tl)
{
if (!tl->db) {
return false;
}

if (!tl->table_name) {
return false;
}

return (!strcmp("performance_schema", tl->db) &&
strcmp(tl->table_name, "threads") &&
strstr(tl->table_name, "setup_") == NULL);
}

@adofsauron
Copy link
Collaborator Author

The continuity test is unstable:

#!/bin/bash
 
/stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " set global  log_bin_trust_function_creators=1; "
 
index=0
while [[ true ]]; do
    value="VALUE FOR $index"
 
    echo /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e "
        SELECT FIND_TOP_USID(C.USID) AS SUSID,
            C2.CORPNAME AS SCORPNAME,
            C2.BNAME,
            C.USID,
            C.CORPNAME,
            C.IBUSINESSID,
            C.TTLB
        FROM CUSTOM C
        LEFT JOIN CUSTOM C2
            ON C2.USID = C.SUSID
        WHERE C.LGTP = '02'
        AND C.USTP = '01'
        AND C.IBUSINESSID = 2;
    " 
    
    /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e "
        SELECT FIND_TOP_USID(C.USID) AS SUSID,
            C2.CORPNAME AS SCORPNAME,
            C2.BNAME,
            C.USID,
            C.CORPNAME,
            C.IBUSINESSID,
            C.TTLB
        FROM CUSTOM C
        LEFT JOIN CUSTOM C2
            ON C2.USID = C.SUSID
        WHERE C.LGTP = '02'
        AND C.USTP = '01'
        AND C.IBUSINESSID = 2;
    " 
 
    echo /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " show warnings; "
    
    /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " show warnings; "
 
    echo /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " show tables; "
    
    /stonedb57/install/bin/mysql -uroot -pstonedb123 -S /stonedb57/install/tmp/mysql.sock -D dingyou -e " show tables; "
 
 
    echo "index: $index over"
    
    let index++  
 
    if [[ 10000 == $index ]]; then
        break
    fi
 
    #sleep 0.5s
 
done

@RingsC
Copy link
Contributor

RingsC commented Oct 18, 2022

same as #474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants