[MDEV-31318] Spider: ERROR 1400 (XAE09): XAER_OUTSIDE: Some work is done outside global transaction / [ERROR] Got error 1400 when reading table Created: 2023-05-20  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - Spider, XA
Affects Version/s: 10.4, 10.5, 10.6, 10.9, 10.10, 10.11, 11.0, 11.1
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Yuchen Pei
Resolution: Unresolved Votes: 0
Labels: affects-tests

Issue Links:
Relates

 Description   

INSTALL PLUGIN Spider SONAME 'ha_spider.so';
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock',DATABASE'',USER'',PASSWORD'');
CREATE TABLE tm (c INT KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c INT KEY) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "tm"';
LOCK TABLES t2 READ;
LOCK TABLES foo WRITE;
XA START 'x';
SELECT 1 FROM t2;

Leads to:

11.1.0 4e5b771e980edfdad5c5414aa62c81d409d585a4 (Debug)

...
11.1.0-dbg>LOCK TABLES foo WRITE;
ERROR 1146 (42S02): Table 'test.foo' doesn't exist
11.1.0-dbg>XA START 'x';
Query OK, 0 rows affected (0.000 sec)
 
11.1.0-dbg>SELECT 1 FROM t2;
ERROR 1400 (XAE09): XAER_OUTSIDE: Some work is done outside global transaction

11.1.0 4e5b771e980edfdad5c5414aa62c81d409d585a4 (Debug)

2023-05-20 15:49:55 4 [ERROR] Got error 1400 when reading table './test/t2'

Bug (or feature/syntax) confirmed present in:
MariaDB: 10.4.30 (dbg), 10.4.30 (opt), 10.5.21 (dbg), 10.5.21 (opt), 10.6.14 (dbg), 10.6.14 (opt), 10.9.7 (dbg), 10.9.7 (opt), 10.10.5 (dbg), 10.10.5 (opt), 10.11.4 (dbg), 10.11.4 (opt), 11.0.2 (dbg), 11.0.2 (opt), 11.1.0 (dbg), 11.1.0 (opt)

Expected output (InnoDB test):

11.1.0 4e5b771e980edfdad5c5414aa62c81d409d585a4 (Debug)

11.1.0-dbg>CREATE TABLE tm (c INT KEY) ENGINE=InnoDB;
Query OK, 0 rows affected (0.014 sec)
 
11.1.0-dbg>CREATE TABLE t2 (c INT KEY) ENGINE=InnoDB;
Query OK, 0 rows affected (0.008 sec)
 
11.1.0-dbg>LOCK TABLES t2 READ;
Query OK, 0 rows affected (0.000 sec)
 
11.1.0-dbg>LOCK TABLES foo WRITE;
ERROR 1146 (42S02): Table 'test.foo' doesn't exist
11.1.0-dbg>XA START 'x';
Query OK, 0 rows affected (0.000 sec)
 
11.1.0-dbg>SELECT 1 FROM t2;
Empty set (0.001 sec)



 Comments   
Comment by Roel Van de Paar [ 2023-05-20 ]

MTR test:

--source include/have_innodb.inc
--let $SOCKET= `SELECT @@global.socket`
INSTALL PLUGIN Spider SONAME 'ha_spider.so';
CREATE USER spider@localhost IDENTIFIED BY 'pwd';
GRANT ALL ON test.* TO spider@localhost;
eval CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET "$SOCKET",DATABASE 'test',USER 'spider',PASSWORD 'pwd');
CREATE TABLE tm (c INT KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c INT KEY) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "tm"';
LOCK TABLES t2 READ;
--error ER_NO_SUCH_TABLE
LOCK TABLES foo WRITE;
XA START 'x';
SELECT 1 FROM t2;

Leads to:

11.1.0 4e5b771e980edfdad5c5414aa62c81d409d585a4

CURRENT_TEST: main.test
mysqltest: At line 13: query 'SELECT 1 FROM t2' failed: ER_XAER_OUTSIDE (1400): XAER_OUTSIDE: Some work is done outside global transaction
 
Warnings from just before the error:
Error 1400 XAER_OUTSIDE: Some work is done outside global transaction

And:

$ cat ./var/log/mysqld.1.err | grep 1400
2023-05-20 15:59:05 4 [ERROR] Got error 1400 when reading table './test/t2'

Comment by Roel Van de Paar [ 2023-05-20 ]

Not a new regression, I found it present as early as January 2022. May have existed before that.

Generated at Thu Feb 08 10:22:56 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.