[MDEV-14090] XA START must be WITH CONSISTENT SNAPSHOT Created: 2017-10-19  Updated: 2023-06-07

Status: Open
Project: MariaDB Server
Component/s: XA
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Yuchen Pei
Resolution: Unresolved Votes: 0
Labels: spider

Issue Links:
Relates
relates to MDEV-5004 Support parallel read transactions on... Open

 Description   

Normally, InnoDB creates transaction read views lazily, on the first access to an InnoDB table, in row_search_for_mysql() or row_search_mvcc().

There is a special statement

START TRANSACTION WITH CONSISTENT SNAPSHOT;

that immediately creates a read view, by invoking

	innobase_hton->start_consistent_snapshot =
		innobase_start_trx_and_assign_read_view;

I believe that XA START should invoke the above method. The benefit would be that if there is no other source of XA COMMIT statements than Spider, and if can guarantee the absence of the following kind of interleaved execution of XA START and XA COMMIT between shards, then Spider should be able get consistent non-locking reads across shards.

A forbidden interleaving between XA COMMIT and XA START

Let us assume that there are two client requests, COMMIT of a write transaction T1 and BEGIN of a read transaction T2 at roughly the same time.

Internally, Spider implements COMMIT by executing XA PREPARE on each shard, and then executing XA COMMIT on each shard. It also should implement BEGIN by executing XA START on each shard.

Let us say that we have shards A and B. The following interleavings are forbidden and must be prevented by some locking inside Spider. If that is the case and if XA START is fixed as proposed above, then we should get a consistent read view across the shards:

A: XA COMMIT t1; XA START t2
B: XA START t2; XA COMMIT t1

That is, the XA COMMIT and XA START must be submitted to (and completed by) each shard in the same order.



 Comments   
Comment by Marko Mäkelä [ 2017-11-07 ]

Note that MariaDB already implements cross-engine START TRANSACTION WITH CONSISTENT SNAPSHOT. For this fix, XA START would have to invoke that logic.

Comment by Jacob Mathew (Inactive) [ 2018-05-03 ]

Kentoku acknowledges that this can be a problem.

Comment by Kentoku Shiba (Inactive) [ 2019-05-03 ]

marko
I think the following things are required for read consistency (without locks) of sharding environment. How do you think about it?

For read consistency without lock on each data nodes,
Each STARTs TRANSACTIONs, PREPAREs, COMMITs must be regarded as being done at the same time on each data nodes. (REPEATABLE READ)
Also each SELECTs without lock must be regarded as being done at the same time on each data nodes for READ COMMITTED.

Comment by Sergei Golubchik [ 2021-03-23 ]

Doesn't make sense to force consistent snapshot until spider fixes interleaving

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