oceanbase / obproxy

A proxy server for OceanBase Database.
https://open.oceanbase.com
Other
114 stars 79 forks source link

[Bug]: Obproxy executes the prepare statement and reconnects due to disconnection #33

Closed zrcx123 closed 1 year ago

zrcx123 commented 1 year ago

Check Before Asking

Environment

【Product name】obproxy
【Product Version】v3.2.0
[Problem description] After connecting to the cluster through obproxy, execute the prepare statement and report lose connection

Fast Reproduce Steps

select * from oceanbase.__all_virtual_sys_parameter_stat where name="_ob_enable_prepared_statement";

ALTER system set _ob_enable_prepared_statement =true;

MySQL [oceanbase]> select name, data_type, value, scope from oceanbase.__all_virtual_sys_parameter_stat where name='_ob_enable_prepared_statement';

+-------------------------------+-----------+-------+---------+

| name | data_type | value | scope |

+-------------------------------+-----------+-------+---------+

| _ob_enable_prepared_statement | NULL | True | CLUSTER |

| _ob_enable_prepared_statement | NULL | True | CLUSTER |

| _ob_enable_prepared_statement | NULL | True | CLUSTER |

+-------------------------------+-----------+-------+---------+

MySQL [oceanbase]> select version();

+--------------------+

| version() |

+--------------------+

| 3.1.2-OceanBase CE |

+--------------------+

1 row in set (0.00 sec)

Executing prepare through proxy still fails:

MySQL [test]> prepare stmt1 from 'INSERT INTO test.tb1 (id , name ) values ( ? , ? )';

Query OK, 0 rows affected (0.00 sec)

MySQL [test]> prepare stmt1 from 'INSERT INTO test.tb1 (id , name ) values ( ? , ? )';

ERROR 2013 (HY000): Lost connection to MySQL server during query

MySQL [test]> prepare stmt1 from 'INSERT INTO test.tb1 (id , name ) values ( ? , ? )';

ERROR 2006 (HY000): MySQL server has gone away

No connection. Trying to reconnect...

Connection id: 655372

Current database: test

Query OK, 0 rows affected (0.01 sec)

Direct connection to the observer to execute prepare will not cause a broken link:

MySQL [test]> prepare stmt1 from 'INSERT INTO test.tb1 (id , name ) values ( ? , ? )';

Query OK, 0 rows affected (0.01 sec)

MySQL [test]> prepare stmt1 from 'INSERT INTO test.tb1 (id , name ) values ( ? , ? )';

Query OK, 0 rows affected (0.00 sec)

MySQL [test]> prepare stmt1 from 'INSERT INTO test.tb1 (id , name ) values ( ? , ? )';

Query OK, 0 rows affected (0.00 sec)

Actual Behavior

The obproxy_error log content is as follows:

[time],undefined,,,,[clustername]:sys:test,OB_MYSQL,tb1,tb1,OB_MYSQL_COM_QUERY,TEXT_PS_PREPARE,failed,-4016,prepare stmt1 from 'INSERT INTO test.tb1 (id %2C name ) values ( ? %2C ? )',118us,0us,0us,0us,Y0-7F7D0BE0D3A0,,,,0,,Ooooooooooooops

Expected Behavior

No response

Other Information

No response

longdafeng commented 1 year ago

This bug has been fixed in 4.0

mysql> CREATE TABLE test (
id INT NOT NULL,
name varchar(20)
);
Query OK, 0 rows affected (0.11 sec)
mysql> prepare stmt1 from 'INSERT INTO test (id , name ) values ( ? , ? )';
Query OK, 0 rows affected (0.34 sec)