Skip to content

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

Closed
@dvilaverde

Description

@dvilaverde

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))
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions