Description:
I find that using XA transaction in MySQL 5.7 will cause slave OOM.
Our production environments are based on read/write split, which means almost read operation will send to slaves. Hence this is a big problem for us.
How to repeat:
test script:
set @id:=floor(rand()*19999999+1);
xa start 'a';
update sbtest.sbtest1 set k = k + 1 where id = @id;
xa end 'a';
xa commit 'a' one phase;
run script on master: mysqlslap -q xa_oom.sql -c 1 --number-of-queries=100000
on slave: you will see a lot of transactions with not started state.
root@test-2:~# mysql -e"show engine innodb status\G" | grep "TRANSACTION" | wc -l
11296
and in error log, you will see following until oom happens:
[Note] InnoDB: Number of pools: 260
[Note] InnoDB: Number of pools: 261
[Note] InnoDB: Number of pools: 262
...