mariadb/mysql-test/include
Sujatha 410e3c1a9a MDEV-17515: GTID Replication in optimistic mode deadlock
Problem:
=======
In slave_parallel_mode=optimistic configuration, when admin commands and
DML operation on the same table are scheduled simultaneously for execution,
it results in lock conflict and slave server either hangs due to
deadlock or goes down with an assert.

Analysis:
========
Admin commands OPTIMIZE, REPAIR and ANALYZE are written to binary log as
ordinary transactions. When 'slave_parallel_mode' is 'optimistic' DMLs are
allowed to run in parallel. But these locks are not detected by parallel
replication deadlock detection-and-handling mechanism. At times they result
in deadlock or assertion.

Fix:
===
Flag admin commands as DDL in Gtid_log_event at the time of writing to
binary log. Add a new bit EXECUTED_TABLE_ADMIN_CMD to
'm_unsafe_rollback_flags'. During 'mysql_admin_table' command execution it
accepts a list of tables to be processed and executes them in a loop. Upon
successful execution enable 'EXECUTED_TABLE_ADMIN_CMD' bit in
thd->transaction.stmt_unsafe_rollback_flags. Gtid_log_event constructor
will notice this flag and mark the current transaction with 'FL_DDL' flag.
Gtid_log_events marked as FL_DDL will not be scheduled parallel execution,
on the slave. They will execute in isolation to prevent deadlocks.

Note: Removed the call to 'trans_commit_implicit' from 'mysql_admin_table'
function as 'mysql_execute_command' will take care of invoking
'trans_commit_implicit'.
2021-05-17 16:38:58 +05:30
..
add_anonymous_users.inc
alter_table_mdev539.inc
analyze-format.inc
analyze-sync_with_master.test
analyze-timeout.test
assert.inc
assert_grep.inc
autoinc_mdev15353.inc
begin_include_file.inc
big_test.inc
binlog_inject_error.inc
binlog_parallel_replication_marks.test
binlog_start_pos.inc
bug38347.inc
bytes.inc
bytes2.inc
check-testcase.test
check-warnings.test
check_concurrent_insert.inc
check_events_off.inc
check_ftwrl_compatible.inc
check_ftwrl_incompatible.inc
check_ipv6.inc
check_key_reads.inc
check_key_req.inc
check_no_concurrent_insert.inc
check_no_row_lock.inc
check_shared_row_lock.inc
check_slave_is_running.inc
check_slave_no_error.inc
check_slave_param.inc
check_var_limit.inc
cleanup_fake_relay_log.inc
commit.inc
common-tests.inc
concurrent.inc
connect2.inc
count_sessions.inc
crash_mysqld.inc
ctype_8bit.inc
ctype_ascii_order.inc
ctype_common.inc
ctype_czech.inc
ctype_datetime.inc
ctype_E05C.inc
ctype_filesort.inc
ctype_filesort2.inc
ctype_german.inc
ctype_heap.inc
ctype_innodb_like.inc
ctype_like.inc
ctype_like_cond_propagation.inc
ctype_like_cond_propagation_utf8_german.inc
ctype_like_escape.inc
ctype_like_ignorable.inc
ctype_like_range_f1f2.inc
ctype_like_range_mdev14350.inc
ctype_mdev13118.inc
ctype_myanmar.inc
ctype_numconv.inc
ctype_pad.inc
ctype_pad_all_engines.inc
ctype_pad_space.inc
ctype_regex.inc
ctype_regex_utf8.inc
ctype_str_to_date.inc
ctype_strtoll10.inc
ctype_thai.inc
ctype_uca_w2.inc
ctype_unescape.inc
ctype_unicode520.inc
ctype_unicode_latin.inc
ctype_utf8_ilseq.inc
ctype_utf8_table.inc
ctype_utf8mb4.inc
daemon_example_bad_format.ini
daemon_example_bad_soname.ini
dbt3_s001.inc
ddl_i18n.check_events.inc
ddl_i18n.check_sp.inc
ddl_i18n.check_triggers.inc
ddl_i18n.check_views.inc
deadlock.inc
default_charset.inc
default_client.cnf
default_group_order.cnf
default_my.cnf
default_mysqld.cnf
default_optimizer_switch.inc
delete_anonymous_users.inc
diff_servers.inc
diff_tables.inc
end_include_file.inc
endspace.inc
equal_fields_propagation_datetime.inc
expect_crash.inc
explain_non_select.inc
explain_utils.inc
file_does_not_exist.inc
filter_file.inc
force_restart.inc
func_hybrid_type.inc
func_str_ascii_checksum.inc
function_defaults.inc
function_defaults_notembedded.inc
galera_clear_sync_point.inc
galera_cluster.inc
galera_connect.inc
galera_diff.inc
galera_end.inc
galera_have_debug_sync.inc
galera_init.inc
galera_resume.inc
galera_set_sync_point.inc
galera_signal_sync_point.inc
galera_suspend.inc
galera_wait_ready.inc
galera_wait_sync_point.inc
gap_lock_error_all.inc
gap_lock_error_cleanup.inc
gap_lock_error_init.inc
gap_lock_error_select.inc
gap_lock_error_update.inc
get_relay_log_pos.inc
gis_debug.inc
gis_generic.inc
gis_keys.inc
grant_cache.inc
have_32bit.inc
have_64bit.inc
have_archive.inc
have_archive.opt
have_aria.inc
have_aria_used_for_temp_tables.inc
have_big5.inc
have_binlog_checksum_off.inc
have_binlog_format_mixed.inc
have_binlog_format_mixed.opt
have_binlog_format_mixed_or_row.inc
have_binlog_format_mixed_or_statement.inc
have_binlog_format_row.inc
have_binlog_format_row.opt
have_binlog_format_row_or_statement.inc
have_binlog_format_statement.inc
have_binlog_format_statement.opt
have_blackhole.inc
have_blackhole.opt
have_case_insensitive_file_system.inc
have_case_insensitive_fs.inc
have_case_sensitive_file_system.inc
have_collation.inc
have_compress.inc
have_cp866.inc
have_cp932.inc
have_cp1250_ch.inc
have_cp1251.inc
have_crypt.inc
have_csv.inc
have_dbi_dbd-mysql.inc
have_debug.inc
have_debug_sync.inc
have_des.inc
have_eucjpms.inc
have_euckr.inc
have_example_plugin.inc
have_file_key_management.inc
have_garbd.inc
have_gb2312.inc
have_gbk.inc
have_geometry.inc
have_hostname_cache.inc
have_innodb.combinations
have_innodb.inc
have_innodb_4k.inc
have_innodb_8k.inc
have_innodb_16k.inc
have_innodb_32k.inc
have_innodb_64k.inc
have_innodb_disallow_writes.inc
have_innodb_max_16k.inc
have_ipv4_mapped.inc
have_koi8r.inc
have_latin2_ch.inc
have_local_infile.inc
have_log_bin-master.opt
have_log_bin-slave.opt
have_log_bin.inc
have_lowercase0.inc
have_lowercase1.inc
have_lowercase2.inc
have_maria.inc
have_mariabackup.inc
have_max_indexes_64.inc
have_max_indexes_128.inc
have_metadata_lock_info.inc
have_metadata_lock_info.opt
have_mutex_deadlock_detector.inc
have_numa.inc
have_openssl.inc
have_outfile.inc
have_partition.inc
have_partition.opt
have_perfschema.inc
have_plugin_auth.inc
have_plugin_auth.opt
have_plugin_interface.inc
have_plugin_server.inc
have_pool_of_threads.inc
have_profiling.inc
have_query_cache.inc
have_rbr_triggers.inc
have_semisync.inc
have_semisync.opt
have_semisync_plugin.inc
have_sequence.inc
have_sequence.opt
have_simple_parser.inc
have_sjis.inc
have_ssl_communication.inc
have_ssl_crypto_functs.inc
have_stat_tables.inc
have_stat_tables.opt
have_static_innodb.inc
have_symlink.inc
have_tis620.inc
have_ucs2.inc
have_udf.inc
have_ujis.inc
have_unix_socket.inc
have_utf8.inc
have_utf8mb4.inc
have_utf16.inc
have_utf32.inc
have_working_dns.inc
have_wsrep.inc
have_wsrep_enabled.inc
have_wsrep_provider.inc
have_xtrabackup.inc
have_xtradb.combinations
have_xtradb.inc
icp_debug_kill.inc
icp_tests.inc
implicit_commit_helper.inc
index_merge1.inc
index_merge2.inc
index_merge_2sweeps.inc
index_merge_ror.inc
index_merge_ror_cpk.inc
innodb-index.inc
innodb_encrypt_log.combinations
innodb_encrypt_log.inc
innodb_encrypt_tables.combinations
innodb_encrypt_tables.inc
innodb_page_size.combinations
innodb_page_size.inc
innodb_page_size_small.combinations
innodb_page_size_small.inc
innodb_prefix_index_cluster_optimization.combinations
innodb_prefix_index_cluster_optimization.inc
innodb_rollback_on_timeout.inc
innodb_row_format.combinations
innodb_row_format.inc
innodb_trx_weight.inc
innodb_undo_tablespaces.combinations
innodb_undo_tablespaces.inc
install_semisync.inc
io_thd_fault_injection.inc
ipv6.inc
ipv6_clients.inc
is_embedded.inc
kill_binlog_dump_threads.inc
kill_mysqld.inc
kill_query.inc
kill_query_and_diff_master_slave.inc
libdaemon_example.ini
linux.inc
linux_sys_vars.inc
load_sysvars.inc
loaddata_autocom.inc
long_test.inc
maria_empty_logs.inc
maria_make_snapshot.inc
maria_make_snapshot_for_comparison.inc
maria_make_snapshot_for_feeding_recovery.inc
maria_verify_recovery.inc
master-slave.inc
max_indexes.inc
maybe_debug.combinations
maybe_debug.inc
min_null_cond.inc
mix1.inc
mix2.inc
mix2_ucs2.inc
mrr_tests.inc
mtr_check.sql
mtr_warnings.sql
mysql_upgrade_preparation.inc
mysqladmin_shutdown.inc
mysqlbinlog_have_debug.inc
mysqldump.inc
mysqlhotcopy.inc
mysqltest-x.inc
no_protocol.inc
no_running_event_scheduler.inc
no_running_events.inc
no_valgrind_without_big.inc
not_as_root.inc
not_binlog_format_row.inc
not_blackhole.inc
not_crashrep.inc
not_debug.inc
not_embedded.inc
not_encrypted.inc
not_parallel.inc
not_ssl.inc
not_staging.inc
not_threadpool.inc
not_valgrind.inc
not_var_link.inc
not_windows.inc
not_windows_embedded.inc
one_thread_per_connection.inc
parser_bug21114.inc
partition_date_range.inc
platform.combinations
platform.inc
plugin.defs
ps_conv.inc
ps_create.inc
ps_ddl_1.inc
ps_modify.inc
ps_modify1.inc
ps_query.inc
ps_renew.inc
query_cache.inc
query_cache_partitions.inc
query_cache_sql_prepare.inc
read_many_rows.inc
relocate_binlogs.inc
require_openssl_client.inc
reset_master_slave.inc
restart_mysqld.inc
restart_slave_sql.inc
restore_charset.inc
rowid_order.inc
rpl_assert.inc
rpl_change_topology.inc
rpl_connect.inc
rpl_connection.inc
rpl_diff.inc
rpl_end.inc
rpl_events.inc
rpl_for_each_slave.inc
rpl_generate_sync_chain.inc
rpl_init.combinations
rpl_init.inc
rpl_ip_mix.inc
rpl_ip_mix2.inc
rpl_ipv6.inc
rpl_loaddata_charset.inc
rpl_multi_engine.inc
rpl_multi_engine2.inc
rpl_multi_engine3.inc
rpl_reconnect.inc
rpl_reset.inc
rpl_restart_server.inc
rpl_row_img_general_loop.inc
rpl_row_img_set.inc
rpl_start_server.inc
rpl_start_slaves.inc
rpl_stmt_seq.inc
rpl_stop_server.inc
rpl_stop_slaves.inc
rpl_sync.inc
rpl_udf.inc
running_event_scheduler.inc
save_master_gtid.inc
save_master_pos.inc
search_pattern_in_file.inc
set_binlog_format_mixed.sql
set_binlog_format_row.sql
set_binlog_format_statement.sql
setup_fake_relay_log.inc
show_all_slaves_status.inc
show_binary_logs.inc
show_binlog_events.inc
show_binlog_events2.inc
show_binlog_using_logname.inc
show_delayed_slave_state.inc
show_events.inc
show_gtid_list.inc
show_master_logs.inc
show_master_status.inc
show_msg.inc
show_msg80.inc
show_relaylog_events.inc
show_rpl_debug_info.inc
show_slave_hosts.inc
show_slave_status.inc
shutdown_mysqld.inc
sp-vars.inc
start_mysqld.inc
start_slave.inc
stop_dump_threads.inc
stop_slave.inc
stop_slave_io.inc
stop_slave_sql.inc
strict_autoinc.inc
subselect_mat_cost.inc
support_long_file_names.inc
sync_io_with_master.inc
sync_slave_io_with_master.inc
sync_slave_sql_with_io.inc
sync_slave_sql_with_master.inc
sync_with_master.inc
sync_with_master_gtid.inc
system_db_struct.inc
test_fieldsize.inc
test_outfile.inc
testdb_only.inc
tpcb.inc
tpcb_disk_data.inc
truncate_file.inc
type_hrtime.inc
type_temporal_zero_default.inc
uninstall_semisync.inc
unsafe_binlog.inc
uses_vardir.inc
varchar.inc
view_alias.inc
wait_condition.inc
wait_condition_sp.inc
wait_condition_with_debug.inc
wait_for_binlog_checkpoint.inc
wait_for_binlog_event.inc
wait_for_line_count_in_file.inc
wait_for_purge.inc
wait_for_query_to_fail.inc
wait_for_query_to_succeed.inc
wait_for_slave_io_error.inc
wait_for_slave_io_to_start.inc
wait_for_slave_io_to_stop.inc
wait_for_slave_param.inc
wait_for_slave_sql_error.inc
wait_for_slave_sql_error_and_skip.inc
wait_for_slave_sql_to_start.inc
wait_for_slave_sql_to_stop.inc
wait_for_slave_to_start.inc
wait_for_slave_to_stop.inc
wait_for_sql_thread_read_all.inc
wait_for_status_var.inc
wait_show_condition.inc
wait_until_connected_again.inc
wait_until_count_sessions.inc
wait_until_disconnected.inc
wait_until_ready.inc
wait_until_rows_count.inc
wait_wsrep_ready.inc
weight_string.inc
weight_string_8EA1.inc
weight_string_8FA2C3.inc
weight_string_8140.inc
weight_string_A1A1.inc
weight_string_chde.inc
weight_string_euro.inc
weight_string_l1.inc
weight_string_l2.inc
weight_string_l3.inc
weight_string_l4.inc
weight_string_l12.inc
weight_string_l14.inc
windows.inc
windows_sys_vars.inc
word_size.combinations
word_size.inc
world.inc
world_schema.inc
world_schema1.inc
world_schema_utf8.inc
write_result_to_file.inc
write_var_to_file.inc