Skip to content

Enabling compression on client connection results in "connection was bad" error #862

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

Closed
dvilaverde opened this issue May 2, 2024 · 4 comments

Comments

@dvilaverde
Copy link
Contributor

When compression is enabled on the client my application fails with connection was bad, the nested exception is:

io.CopyN failed. err unexpected EOF, copied 0, expected 29

But when disabling compression the application works correctly.

Repro Steps

Start MariaDB in Docker:

docker run --rm -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mariadb:10.3.39

Create the DB and table found in the attached file

db_schema.txt

Run this test:

import (
  "github.com/go-mysql-org/go-mysql/client"
  "github.com/go-mysql-org/go-mysql/mysql"
  "github.com/stretchr/testify/assert"
)

func TestServer_ShowFieldTable1(t *testing.T) {
	a := assert.New(t)

	c, err := client.Connect("localhost:3306", "root", "root", "mydb", func(conn *client.Conn) {
		conn.SetCapability(mysql.CLIENT_COMPRESS) // Disable compression and the test will pass
	})
	a.NoError(err)

	execute, err := c.Execute("SHOW FIELDS FROM mydb.table1")
	if a.NoError(err) {
		rs := execute.Resultset
		a.Equal(575, len(rs.RowDatas))
	}
}

@dvilaverde
Copy link
Contributor Author

Some more context in case it helps. I notice that setting net_buffer_length on the server causes the above test case to pass, for example:

set global net_buffer_length=32768;

then resetting it lot the original value will revert to the previous failing behavior.

set global net_buffer_length=16384;

@dveeden
Copy link
Collaborator

dveeden commented May 3, 2024

Thanks for the bugreport. I'll try to reproduce this.

@dvilaverde
Copy link
Contributor Author

I've created a PR that seems to fix this in my fork: #863

@dvilaverde
Copy link
Contributor Author

Merged #863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants