[MDEV-13155] XA recovery not supported for RocksDB Created: 2017-06-22  Updated: 2019-01-20  Resolved: 2018-11-28

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - RocksDB, XA
Affects Version/s: 10.2
Fix Version/s: 10.2.20, 10.3.12

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Petrunia
Resolution: Fixed Votes: 0
Labels: None
Environment:

10.2 0992be927e1c686c39c39fe53fc2a7869d55143d



 Description   

I'm not sure whether it's supposed to work. If it's not, it should probably be documented.

# Run with --mysqld=--plugin-load-add=ha_rocksdb
 
--connect (con1,localhost,root,,test)
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT) ENGINE=RocksDB;
 
XA START 'xa1';
INSERT INTO t1 (a) VALUES (1),(2);
XA END 'xa1';
XA PREPARE 'xa1';
 
--connect (con2,localhost,root,,test)
XA START 'xa2';
INSERT INTO t1 (a) VALUES (3);
INSERT INTO t1 (a) VALUES (4);
XA END 'xa2';
XA PREPARE 'xa2';
 
--connection default
sleep 1;
 
--let $shutdown_timeout= 0
--source include/restart_mysqld.inc
 
--connect (con3,localhost,root,,test)
--disable_abort_on_error
XA RECOVER;
XA ROLLBACK 'xa1';
XA COMMIT 'xa2';
SELECT a FROM t1;
DROP TABLE t1;

Both transactions are forgotten after recovery:

connect  con3,localhost,root,,test;
XA RECOVER;
formatID	gtrid_length	bqual_length	data
XA ROLLBACK 'xa1';
ERROR XAE04: XAER_NOTA: Unknown XID
XA COMMIT 'xa2';
ERROR XAE04: XAER_NOTA: Unknown XID
SELECT a FROM t1;
a
DROP TABLE t1;



 Comments   
Comment by Sergei Petrunia [ 2018-11-28 ]

Seems to work in the current code.
One needs to have rocksdb_flush_log_at_trx_commit=1 (the compile default, but MTR uses 0 for speed) otherwise killing the server may remove the changes.

Comment by Valerii Kravchuk [ 2019-01-19 ]

Why "Dix Version/s" say 10.3.12? For me XA RECOVER etc work on 10.3.7 as well:

MariaDB [test]> select * from trocks;
+----+------+
| id | c1   |
+----+------+
|  1 |    1 |
+----+------+
1 row in set (0.008 sec)
 
MariaDB [test]> show create table trocks\G
*************************** 1. row ***************************
       Table: trocks
Create Table: CREATE TABLE `trocks` (
  `id` int(11) NOT NULL,
  `c1` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1
1 row in set (0.001 sec)
 
MariaDB [test]> xa start 'xa1';
Query OK, 0 rows affected (0.001 sec)
 
MariaDB [test]> insert into trocks values (2,2);
Query OK, 1 row affected (0.002 sec)
 
MariaDB [test]> xa end 'xa1';
Query OK, 0 rows affected (0.001 sec)
 
MariaDB [test]> xa prepare 'xa1';
Query OK, 0 rows affected (0.033 sec)
 
MariaDB [test]> select * from trocks;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (10061)
ERROR: Can't connect to the server

I killed the server, now upon restart we see in the log:

...
2019-01-19 16:08:48 0 [Note] InnoDB: 10.3.7 started; log sequence number 6117865
3; transaction id 39687
2019-01-19 16:08:48 0 [Note] InnoDB: Loading buffer pool(s) from C:\Program File
s\MariaDB 10.3\data\ib_buffer_pool
2019-01-19 16:08:48 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-01-19 16:08:48 0 [Note] Recovering after a crash using pc-PC-bin
2019-01-19 16:08:48 0 [Note] Starting crash recovery...
2019-01-19 16:08:48 0 [Note] Found 1 prepared transaction(s) in ROCKSDB
2019-01-19 16:08:48 0 [Warning] Found 1 prepared XA transactions
2019-01-19 16:08:48 0 [Note] Crash recovery finished.
2019-01-19 16:08:48 0 [Note] Found 1 prepared transaction(s) in ROCKSDB
2019-01-19 16:08:49 0 [Warning] Found 1 prepared XA transactions
2019-01-19 16:08:49 0 [Note] Server socket created on IP: '::'.
2019-01-19 16:08:49 0 [Note] Reading of all Master_info entries succeded
2019-01-19 16:08:49 0 [Note] Added new Master_info '' to hash table
2019-01-19 16:08:49 0 [Note] mysqld: ready for connections.
Version: '10.3.7-MariaDB-log'  socket: ''  port: 3316  mariadb.org binary distribution
2019-01-19 16:08:53 0 [Note] InnoDB: Buffer pool(s) load completed at 190119 16:08:53

Transaction is there in prepared state:

MariaDB [test]> \r
Connection id:    10
Current database: test
 
MariaDB [test]> select * from trocks;
+----+------+
| id | c1   |
+----+------+
|  1 |    1 |
+----+------+
1 row in set (0.003 sec)
 
MariaDB [test]> xa recover;
+----------+--------------+--------------+------+
| formatID | gtrid_length | bqual_length | data |
+----------+--------------+--------------+------+
|        1 |            3 |            0 | xa1  |
+----------+--------------+--------------+------+
1 row in set (0.001 sec)
 
MariaDB [test]> insert into trocks values (2,2);
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
MariaDB [test]> xa rollback 'xa1';
Query OK, 0 rows affected (0.045 sec)
 
MariaDB [test]> xa recover;
Empty set (0.001 sec)
 
MariaDB [test]> select * from trocks;
+----+------+
| id | c1   |
+----+------+
|  1 |    1 |
+----+------+
1 row in set (0.003 sec)

Comment by Sergei Petrunia [ 2019-01-20 ]

I have set fixVersion to the version that I have pushed the testcase into. I'm not sure which specific revision fixed it. valerii do you think it is worth the time to find that out?
(btw, is there any particular reason you are using different testcase from the one in the bug report? I suppose either should be fine for checking if XA is working, or there's some difference?)

Comment by Valerii Kravchuk [ 2019-01-20 ]

Current setting may be interpreted as the problem was fixed only in 10.3.12 and in all previous versions your test case fails. I think checking it with all 10.3 GA versions at least (and maybe recent 10.2.x) makes sense.

My test is from my work on other cases (people stated there is a difference how MyRocks works vs InnoDB when mysqld crashes), then I was looking for known XA bugs related to MyRocks, found this one and decided to add that it must already work in 10.3.7 based on what I've seen).

Generated at Thu Feb 08 08:03:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.