mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-8354: out-of-order error with --gtid-ignore-duplicates and row-based replication
The --gtid-ignore-duplicates option was not working correctly with row-based replication. When a row event was completed, but before committing, there was a small window where another multi-source SQL thread could wrongly try to re-execute the same transaction, without properly ignoring the duplicate GTID. This would lead to duplicate key error or out-of-order GTID error or similar. Thanks to Matt Neth for reporting this and giving an easy way to reproduce the issue.
This commit is contained in:
@@ -1788,6 +1788,13 @@ void rpl_group_info::cleanup_context(THD *thd, bool error)
|
||||
rli->clear_flag(Relay_log_info::IN_STMT);
|
||||
rli->clear_flag(Relay_log_info::IN_TRANSACTION);
|
||||
}
|
||||
|
||||
/*
|
||||
Ensure we always release the domain for others to process, when using
|
||||
--gtid-ignore-duplicates.
|
||||
*/
|
||||
if (gtid_ignore_duplicate_state != GTID_DUPLICATE_NULL)
|
||||
rpl_global_gtid_slave_state.release_domain_owner(this);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1796,13 +1803,6 @@ void rpl_group_info::cleanup_context(THD *thd, bool error)
|
||||
thd->variables.option_bits&= ~OPTION_NO_FOREIGN_KEY_CHECKS;
|
||||
thd->variables.option_bits&= ~OPTION_RELAXED_UNIQUE_CHECKS;
|
||||
|
||||
/*
|
||||
Ensure we always release the domain for others to process, when using
|
||||
--gtid-ignore-duplicates.
|
||||
*/
|
||||
if (gtid_ignore_duplicate_state != GTID_DUPLICATE_NULL)
|
||||
rpl_global_gtid_slave_state.release_domain_owner(this);
|
||||
|
||||
/*
|
||||
Reset state related to long_find_row notes in the error log:
|
||||
- timestamp
|
||||
@@ -1811,6 +1811,11 @@ void rpl_group_info::cleanup_context(THD *thd, bool error)
|
||||
reset_row_stmt_start_timestamp();
|
||||
unset_long_find_row_note_printed();
|
||||
|
||||
DBUG_EXECUTE_IF("inject_sleep_gtid_100_x_x", {
|
||||
if (current_gtid.domain_id == 100)
|
||||
my_sleep(50000);
|
||||
};);
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user