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

variable max_allowed_packet does not take effect #32164

Closed
aylei opened this issue Feb 8, 2022 · 2 comments
Closed

variable max_allowed_packet does not take effect #32164

aylei opened this issue Feb 8, 2022 · 2 comments
Labels
may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@aylei
Copy link

aylei commented Feb 8, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

TiDB:

# run a tidb-server with 2GB memory limit
> docker run -p 4000:4000 -m 2048m  pingcap/tidb:v5.3.0

> mysql -h 127.0.0.1 -P4000 -uroot  -Dtest -e 'select @@max_allowed_packet'
+----------------------+
| @@max_allowed_packet |
+----------------------+
|             67108864 |
+----------------------+

# prepare a large `INSERT INTO` sql
> du -sh ./sql.txt
720M	./sql.txt

# execute the sql and OOM observed
> mysql -h 127.0.0.1 -P4000 -uroot  -Dtest < sql.txt
ERROR 2013 (HY000) at line 1: Lost connection to MySQL server during query

TiDB OOM observed during executing the SQL.

MySQL:

> du -sh sql.txt
 96M	sql.txt

> mysql -h 127.0.0.1 -P3306 -uroot  -Dtest -e 'select @@max_allowed_packet'
+----------------------+
| @@max_allowed_packet |
+----------------------+
|             67108864 |
+----------------------+

# mysql server close the connection but not OOM
> mysql -h 127.0.0.1 -P3306 -uroot  -Dtest < sql.txt
ERROR 2006 (HY000) at line 1: MySQL server has gone away

# use larger max_allowed_packet
> mysql -h 127.0.0.1 -P3306 -uroot  -Dtest -e 'set @@global.max_allowed_packet=671088640'

> mysql -h 127.0.0.1 -P3306 -uroot  -Dtest -e 'select @@max_allowed_packet'
+----------------------+
| @@max_allowed_packet |
+----------------------+
|            671088640 |
+----------------------+

# after enlarge max_allowed_packet, the sql execution succeeds
> mysql -h 127.0.0.1 -P3306 -uroot  -Dtest < sql.txt
(succeed)

Also, according to the documentation, mysql will check the packet size on server-side https://dev.mysql.com/doc/refman/8.0/en/packet-too-large.html

2. What did you expect to see? (Required)

TiDB reject the sql that exceeds max_allowed_packet

3. What did you see instead (Required)

TiDB accept the SQL and run into OOM

4. What is your TiDB version? (Required)

v5.3.0

@aylei aylei added the type/bug The issue is confirmed as a bug. label Feb 8, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Feb 9, 2022
@mjonss
Copy link
Contributor

mjonss commented Feb 9, 2022

Duplicate of #31422. I will close this issue and add a comment in the referred issue, that it also can cause OOM.

@bb7133
Copy link
Member

bb7133 commented Feb 10, 2022

Interesting...max_allowed_packet is not actually implemented in the current protocol handling implementations.

Close this issue as stated by @mjonss , let's track it in #31422.

@bb7133 bb7133 closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants