matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.79k stars 276 forks source link

[Bug]: when cn label is empty,statement_info unable find account user information #9326

Closed heni02 closed 1 year ago

heni02 commented 1 year ago

Is there an existing issue for the same bug?

Environment

- Version or commit-id (e.g. v0.1.0 or 8b23a93):nightly-365ecb68
- Hardware parameters:
- OS type:
- Others:

Actual Behavior

When cn groups label is empty, any account who is not in the group login mo, execute SQL, and statement_info not found the account user information image image

Expected Behavior

No response

Steps to Reproduce

1. mo cn groups config:
cnLabels: []

2.mysql -h 127.0.0.1 -P6501 -uc2:admin -p111 
create table hhh(c1 int); 
3.select node_uuid,statement,user from system.statement_info where account='c2' ;

Additional information

No response

volgariver6 commented 1 year ago

再操做一遍,无法复现该问题。

gouhongshen commented 1 year ago

according to the above statements and steps, tried:

  1. single tenant did random queries
  2. multiple tenants did random queries

but can not repo.

gouhongshen commented 1 year ago

1. Reason:

this is not a proxy problem. when an internal query with the prefix __++__internal_cmd_field_list has been executed, these codes will be invoked (in pkg/frotend/session.go::getSqlType):

if tenant == nil || strings.HasPrefix(sql, cmdFieldListSql) {
    if tenant != nil {
        tenant.SetUser("")
    }
    ses.sqlSourceType = append(ses.sqlSourceType, intereSql)
    return
}

and the tenant.user , which has been set to "", will be cached and valid in subsequent queries until re-establish SQL connection.

2. Steps to Repo:

0. open a terminal
1. mysql -h127.0.0.1 -udump -P6001 -p111;
2. create account acc1 admin_name 'root' identified by '111';
3. open a new terminal
4. mysql -h127.0.0.1 -uacc1:root -P6009 -p111;
5. launch some queries
6. select node_uuid,statement,account,user from system.statement_info where account='acc1' ;

7. __++__internal_cmd_field_list ; -- this will occur panic err, but it doesn't matter.
8. launch some queries
9. select node_uuid,statement,account,user from system.statement_info where account='acc1' ;

then you will see that some statement records  have lost the user info

but I have no idea about why and when this internal query will be executed yet.

gouhongshen commented 1 year ago

put on hold, give priority to #10089

gouhongshen commented 1 year ago

1. Reason:

this is not a proxy problem. when an internal query with the prefix __++__internal_cmd_field_list has been executed, these codes will be invoked (in pkg/frotend/session.go::getSqlType):

if tenant == nil || strings.HasPrefix(sql, cmdFieldListSql) {
    if tenant != nil {
        tenant.SetUser("")
    }
    ses.sqlSourceType = append(ses.sqlSourceType, intereSql)
    return
}

and the tenant.user , which has been set to "", will be cached and valid in subsequent queries until re-establish SQL connection.

2. Steps to Repo:

0. open a terminal
1. mysql -h127.0.0.1 -udump -P6001 -p111;
2. create account acc1 admin_name 'root' identified by '111';
3. open a new terminal
4. mysql -h127.0.0.1 -uacc1:root -P6009 -p111;
5. launch some queries
6. select node_uuid,statement,account,user from system.statement_info where account='acc1' ;

7. __++__internal_cmd_field_list ; -- this will occur panic err, but it doesn't matter.
8. launch some queries
9. select node_uuid,statement,account,user from system.statement_info where account='acc1' ;

then you will see that some statement records  have lost the user info

but I have no idea about why and when this internal query will be executed yet.

发起 cmdFieldList query 是因为使用 TAB 键补全表名

heni02 commented 1 year ago

@xzxiong confirmed ,it is same issue as #10542 ,so closed

xzxiong commented 1 year ago

@xzxiong confirmed ,it is same issue as #10542 ,so closed

confirmed