Bug #86902 | Dead lock cause mysqld hand | ||
---|---|---|---|
Submitted: | 3 Jul 2017 7:10 | Modified: | 12 Jul 2017 2:08 |
Reporter: | qinglin zhang (OCA) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 5.6 | OS: | Linux |
Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
Tags: | log_xid |
[3 Jul 2017 7:10]
qinglin zhang
[7 Jul 2017 0:05]
MySQL Verification Team
Hi, Thanks for the report, looking at this I have issues reproducing. Can you share the config you are using, show global status and show global variables values? all best Bogdan
[7 Jul 2017 2:08]
qinglin zhang
HI, Bogdan. I just turn off binlog and load data from clients and cause mysqld's hang. I found the problem by gdb the context and analyze the function named TC_LOG_MMAP::log_xid. # cat my.cnf [mysqld_safe] [mysql] port=3306 prompt=\\u@\\d \\r:\\m:\\s> default-character-set=utf8 # UTF-8 no-auto-rehash skip-insecure-warning # We may use passwd in scripts, [client] port=3306 #innodb innodb_stats_persistent=0 innodb_stats_auto_recalc=OFF innodb_data_file_path = ibdata1:4G;ibdata2:16M:autoextend innodb_buffer_pool_size=8G innodb_buffer_pool_instances=8 innodb_log_files_in_group=4 innodb_log_file_size=2G innodb_log_buffer_size=32M innodb_flush_log_at_trx_commit=1 innodb_max_dirty_pages_pct_lwm=10 innodb_max_dirty_pages_pct=60 innodb_thread_concurrency=16 innodb_read_io_threads=8 innodb_write_io_threads=1 innodb_open_files=60000 innodb_file_format=Barracuda innodb_file_per_table=1 innodb_flush_method=O_DIRECT innodb_change_buffering=all innodb_adaptive_flushing=ON innodb_flush_neighbors=0 innodb_adaptive_hash_index=OFF innodb_old_blocks_time=1000 innodb_stats_on_metadata=OFF innodb_read_ahead_threshold=0 innodb_use_native_aio=1 innodb_lock_wait_timeout=5 innodb_rollback_on_timeout=0 innodb_purge_threads=4 transaction-isolation=READ-COMMITTED innodb_checksum_algorithm=crc32 innodb_disable_sort_file_cache=ON innodb_io_capacity_max=6000 innodb_io_capacity=2000 innodb_page_size=16k innodb_lru_scan_depth=2048 innodb_sync_array_size=16 innodb_print_all_deadlocks binlog_checksum=none log_bin_use_v1_row_events=on explicit_defaults_for_timestamp=off binlog_row_image=FULL binlog_rows_query_log_events=off binlog_stmt_cache_size=32768 # myisam key_buffer=64M myisam_sort_buffer_size=64M concurrent_insert=2 delayed_insert_timeout=300 # replication slave_type_conversions="ALL_NON_LOSSY" slave_net_timeout=4 skip-slave-start sync_master_info=1000 sync_relay_log_info=1000 gtid_mode=ON enforce_gtid_consistency=ON # binlog server_id=3306 binlog_cache_size=32K max_binlog_cache_size=2G max_binlog_size=500M binlog-format=ROW sync_binlog=1 log-slave-updates=1 expire_logs_days=0 rpl_stop_slave_timeout=300 slave_checkpoint_group=1024 slave_checkpoint_period=300 slave_parallel_workers=16 slave_pending_jobs_size_max=1073741824 slave_rows_search_algorithms='TABLE_SCAN,INDEX_SCAN,HASH_SCAN' slave_sql_verify_checksum=off master_verify_checksum=off # TABLE mode is crash-safety, while FILE is not. master_info_repository=TABLE relay_log_info_repository=TABLE # server default-storage-engine=INNODB character-set-server=utf8 # UTF-8 lower_case_table_names=1 skip-external-locking open_files_limit=65536 safe-user-create local-infile=1 max_digest_length=0 log_slow_admin_statements=1 log_warnings=1 long_query_time=1 slow_query_log=1 general_log=0 query_cache_type=0 query_cache_limit=1M query_cache_min_res_unit=1K table_definition_cache=65536 table_open_cache=65536 metadata_locks_hash_instances=256 metadata_locks_cache_size=32768 eq_range_index_dive_limit=200 table_open_cache_instances=16 thread_stack=512K thread_cache_size=256 read_rnd_buffer_size=128K sort_buffer_size=256K join_buffer_size=128K read_buffer_size=128K port=3306 skip-name-resolve skip-ssl max_connections=8500 max_user_connections=8000 max_connect_errors=65536 max_allowed_packet=128M connect_timeout=8 net_read_timeout=30 net_write_timeout=60 back_log=1024 allow-multiple-engines # skip-innodb default-tmp-storage-engine=MyISAM collation-server=utf8_bin
[7 Jul 2017 2:11]
qinglin zhang
Hi Bogdan. Thank you for your response, we can find the problem by analyzing the function TC_LOG_MMAP::log_xid, there are four threads in the TC_LOG_MMAP::log_xid at the same time, the following sequence may cause mysqld hang. T1 ----- waiting for LOCK_active T2 ----- acquire LOCK_active --------------- waiting for p->lock T3 --------------------- aquire p->lock ------------- waiting for LOCK_sync and release p->lock T4 ----- acquire LOCK_sync --------------------------------------- waiting for LOCK_active and release LOCK_sync th
[7 Jul 2017 2:11]
qinglin zhang
Hi Bogdan. Thank you for your response, we can find the problem by analyzing the function TC_LOG_MMAP::log_xid, there are four threads in the TC_LOG_MMAP::log_xid at the same time, the following sequence may cause mysqld hang. T1 ----- waiting for LOCK_active T2 ----- acquire LOCK_active --------------- waiting for p->lock T3 --------------------- aquire p->lock ------------- waiting for LOCK_sync and release p->lock T4 ----- acquire LOCK_sync --------------------------------------- waiting for LOCK_active and release LOCK_sync th
[10 Jul 2017 12:05]
MySQL Verification Team
Hi, In your gdb I see that you have a lock but I don't see what's causing it nor I see any bug there. You stated "I just turn off binlog and load data from clients and cause mysqld's hang. " .. I need more details about this. 1. you stop binlogging on master or on slaves? 2. where do you "load data from clients"? on master? on slaves? 3. how do you "load data from clients"? you are letting your applications connect to master and write to it? you are using sql dump to load data on slaves? you are importing something on master? MySQL, like any other RDBMS can have deadlocks and that's not a bug, it's normal behavior. You can read about it here https://dev.mysql.com/doc/refman/5.7/en/innodb-deadlocks.html and here https://dev.mysql.com/doc/refman/5.7/en/innodb-deadlocks-handling.html I don't see this is a bug attm so please share more details all best Bogdan
[11 Jul 2017 2:16]
qinglin zhang
Hi Bogdan. Thank you again for your response and sorry for trouble you so much. 1) Dead lock is not bug, but this kind of dead lock cause mysqld hang and can't release connections. when connections exceed max_connections, mysqld hang. 2) The problem only exists at master side. 3) My "loading data" is just insert from proxy, nothing more special. Sorry for trouble and thank you very much.
[11 Jul 2017 2:28]
MySQL Verification Team
Hi, > 1) Dead lock is not bug, but this kind of dead lock > cause mysqld hang and can't release connections. when > connections exceed max_connections, mysqld hang. How are your timeouts configured? What does InnoDB monitor states? I don't see anything in the gdb that shows a problem. > 3) My "loading data" is just insert from proxy, nothing more special. This is not something I can reproduce. What I see is that you are having configuration / scaling / performance issue that's right in the MySQL Support alley, not a bug. best regards Bogdan
[11 Jul 2017 2:54]
qinglin zhang
HI. lock timeout is 5 seconds, the context has already gone away, but you can find the bug if you analyze the function named log_xid. Anyway , thank you.
[11 Jul 2017 18:50]
MySQL Verification Team
Hi, > but you can find the bug if you analyze the function named log_xid. not a bug :( As I said going trough support can help you configure your system properly. Partial fix is to disable binlog sync, full solution is to upgrade to 5.7. all best Bogdan
[11 Jul 2017 22:51]
Mark Callaghan
Whether or not this is a bug, tc_log_mmap is a likely problem for anyone trying to use TokuDB or MyRocks. See: https://bugs.mysql.com/bug.php?id=80870 https://bugs.launchpad.net/percona-server/+bug/1550352 https://github.com/facebook/mysql-5.6/issues/227
[12 Jul 2017 2:08]
qinglin zhang
Yeah, we run test with binlog disabled, so there is nothing for binlog to sync. So I think mark is right.
[12 Jul 2017 2:22]
MySQL Verification Team
@qinglin zhang, are you 100% sure sync is off and that binlog is off as the gdb I see shows code executing only when binlog is on @mark, 5.7 and later solves this "properly". While it's not a bug it surely is a "problem" with 5.6, one that is solved in modern mysql all best Bogdan
[12 Jul 2017 5:40]
Mark Callaghan
I am happy to learn this is fixed in modern MySQL. I have fallen behind but MyRocks is moving to MySQL 8 so I will become current.