Skip to content

Failed to execute test in dump package #415

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
bailantaotao opened this issue Aug 29, 2019 · 1 comment
Closed

Failed to execute test in dump package #415

bailantaotao opened this issue Aug 29, 2019 · 1 comment

Comments

@bailantaotao
Copy link

I got errors when i execute test in dump package.

=== RUN   Test
[2019/08/29 13:16:07] [info] dump.go:204 exec mysqldump with [--host=127.0.0.1 --port=3306 --user=root --password=my-secret-pw --master-data --single-transaction --skip-lock-tables --compact --skip-opt --quick --no-create-info --skip-extended-insert --skip-tz-utc --ignore-table=test1.t2 --default-character-set=utf8 --databases test1 test2]
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'test1' AND TABLE_NAME = 't1';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

----------------------------------------------------------------------
FAIL: dump_test.go:95: schemaTestSuite.TestDump

dump_test.go:107:
    c.Assert(err, IsNil)
... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc00000e1c0), Stderr:[]uint8(nil)} ("exit status 2")

[2019/08/29 13:16:08] [info] dump.go:204 exec mysqldump with [--host=127.0.0.1 --port=3306 --user=root --password=my-secret-pw --master-data --single-transaction --skip-lock-tables --compact --skip-opt --quick --no-create-info --skip-extended-insert --skip-tz-utc --default-character-set=utf8 --databases test1 test2]
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Couldn't execute 'SELECT COLUMN_NAME,                       JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"')                FROM information_schema.COLUMN_STATISTICS                WHERE SCHEMA_NAME = 'test1' AND TABLE_NAME = 't1';': Unknown table 'COLUMN_STATISTICS' in information_schema (1109)

----------------------------------------------------------------------
FAIL: dump_test.go:172: schemaTestSuite.TestParse

dump_test.go:180:
    c.Assert(err, IsNil)
... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc000174bc0), Stderr:[]uint8(nil)} ("exit status 2")

OOPS: 4 passed, 2 FAILED
--- FAIL: Test (0.52s)
FAIL

Process finished with exit code 1

My environment:

docker run -d \
  --name mysql  -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_CHARSET=utf8 -e MYSQL_DATABASE=esdb  \
  -v /Users/Test/tmp/lib/mysql:/var/lib/mysql \
  mysql:5.7 \
  mysqld \
  --datadir=/var/lib/mysql \
  --user=mysql \
  --server-id=1 \
  --log-bin=/var/lib/mysql/mysql-bin.log \
  --binlog_do_db=test   

The issue can be solved by add line args = append(args, "--column-statistics=0") on dump.go.

Can you export the args to outside?

@dveeden dveeden closed this as completed Mar 13, 2025
@dveeden
Copy link
Collaborator

dveeden commented Mar 13, 2025

This was fixed by #559

See also:

go-mysql/dump/dumper.go

Lines 103 to 112 in 8458ff6

// New mysqldump versions try to send queries to information_schema.COLUMN_STATISTICS table which does not exist in old MySQL (<5.x).
// And we got error: "Unknown table 'COLUMN_STATISTICS' in information_schema (1109)".
//
// mysqldump may not send this query if it is started with parameter --column-statistics.
// But this parameter exists only for versions >=8.0.2 (https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-2.html).
//
// For environments where the version of mysql-server and mysqldump differs, we try to check this parameter and use it if available.
func (d *Dumper) detectColumnStatisticsParamSupported(helpOutput []byte) bool {
return bytes.Contains(helpOutput, []byte(`--column-statistics`))
}

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