Skip to content

Instantly share code, notes, and snippets.

@wederbrand
Last active September 1, 2017 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wederbrand/72b0afee7a8e0216ca6c3c2c23e71a2a to your computer and use it in GitHub Desktop.
Save wederbrand/72b0afee7a8e0216ca6c3c2c23e71a2a to your computer and use it in GitHub Desktop.
Replicate mysql bug 83295

Background

See this for mysql, it shows the bug this gist demonstrates. https://bugs.mysql.com/bug.php?id=83295

Setup

Download my.cnf and test.sql to an empty directory

Run these in order to see the bug in action

docker run -d -v $(pwd):/etc/mysql/conf.d -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --name mysql mysql:5.7.17
docker exec -it mysql bash
cd /var/lib/mysql
while [ ! -f true.000003 ]; do sleep 1; done
mysql < /etc/mysql/conf.d/test.sql

now check the bin log and compare against the general log

mysqlbinlog true.000004
mysqlbinlog true.000005
tail -n 100 query.log

look for "XA END; XA COMMIT ONE PHASE" in the bin log and "commit" in the general log

to clean up

exit
docker rm -f mysql

[mysqld]
server-id = 1
log-bin = true
binlog-format = STATEMENT
general-log = on
general_log_file = query.log
flush logs;
CREATE DATABASE /*! IF NOT EXISTS*/ xatest;
USE xatest;
DROP TABLE IF EXISTS `xatest`;
CREATE TABLE `xatest` (
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
insert into xatest values (1);
XA START 'xatest';
DELETE FROM xatest where id=1;
XA END 'xatest';
XA COMMIT 'xatest' ONE PHASE;
flush logs;
XA START 'xatest';
DELETE FROM xatest where id=2;
XA END 'xatest';
XA COMMIT 'xatest' ONE PHASE;
flush logs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment