github / gh-ost

GitHub's Online Schema-migration Tool for MySQL
MIT License
12.31k stars 1.25k forks source link

Status message is not properly formatted and contains MISSING on STDERR #1373

Closed icyflame closed 8 months ago

icyflame commented 8 months ago

We recently upgraded from gh-ost v1.0.48 to v1.1.6. Starting in this version, we started seeing the string MISSING in our status messages:

2024-01-31 12:49:54 INFO Copy: 0/0 100.0%!;(MISSING) Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql_bin.000002:79674; Lag: 0.00s, HeartbeatLag: 0.02s, State: migrating; ETA: due

The string MISSING is generally shown when fmt.Sprintf is used with a formatting directive, but the appropriate variable value to replace the formatting directive is missing.

Using git bisect, I found that this particular issue was introduced in the commit https://github.com/github/gh-ost/commit/515aa72d3d9b756e454b0168b4e57bc599b45e36 as part of the PR https://github.com/github/gh-ost/pull/1194. The migration context logger prints information that is being printed to STDOUT to STDERR as well, with the local time as a prefix. The motivation for this is unclear from the PR's description.

If this is a bug report, please provide a test case (e.g., your table definition and gh-ost command) and the error output.

Table definition:

root@localhost [test] > show create table users \G
*************************** 1. row ***************************
       Table: users
Create Table: CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

gh-ost command:

$ ./gh-ost --host=127.0.0.1 --conf=/gh-ost.cnf --database=test --table=users --alter="engine=innodb" --chunk-size=2000 --max-load=Threads_connected=20 --initially-drop-ghost-table --initially-drop-old-table --test-on-replica --switch-to-rbr --verbose
icyflame commented 8 months ago

This issue was fixed after the above PR was merged ✅