MDEV-6676: Optimistic parallel replication

Implement a new mode for parallel replication. In this mode, all transactions
are optimistically attempted applied in parallel. In case of conflicts, the
offending transaction is rolled back and retried later non-parallel.

This is an early-release patch to facilitate testing, more changes to user
interface / options will be expected. The new mode is not enabled by default.
This commit is contained in:
Kristian Nielsen 2014-12-05 16:09:48 +01:00
commit db21fddc37
55 changed files with 2596 additions and 466 deletions

View file

@ -621,6 +621,8 @@ struct rpl_group_info
counting one event group twice.
*/
bool did_mark_start_commit;
/* Copy of flags2 from GTID event. */
uchar gtid_ev_flags2;
enum {
GTID_DUPLICATE_NULL=0,
GTID_DUPLICATE_IGNORE=1,
@ -652,6 +654,36 @@ struct rpl_group_info
inuse_relaylog *relay_log;
uint64 retry_start_offset;
uint64 retry_event_count;
/*
If `speculation' is != SPECULATE_NO, then we are optimistically running
this transaction in parallel, even though it might not be safe (there may
be a conflict with a prior event group).
In this case, a conflict can cause other errors than deadlocks (like
duplicate key for example). So in case of _any_ error, we need to roll
back and retry the event group.
*/
enum enum_speculation {
/*
This transaction was group-committed together on the master with the
other transactions with which it is replicated in parallel.
*/
SPECULATE_NO,
/*
We will optimistically try to run this transaction in parallel with
other transactions, even though it is not known to be conflict free.
If we get a conflict, we will detect it as a deadlock, roll back and
retry.
*/
SPECULATE_OPTIMISTIC,
/*
This transaction got a conflict during speculative parallel apply, or
it was marked on the master as likely to cause a conflict or unsafe to
speculate. So it will wait for the prior transaction to commit before
starting to replicate.
*/
SPECULATE_WAIT
} speculation;
bool killed_for_retry;
rpl_group_info(Relay_log_info *rli_);