Skip to content

Commit ed96b25

Browse files
committed
Bug#30358470 AUTO SYNC INCREASES LIKELIHOOD OF DEADLOCK WHILE ACQUIRING MDL
Problem: -------- Auto sync can potentially trigger an increase in the number of locks being taken on a particular metadata object at specific times such as when a synchronization attempt coincides with a DDL statement or DML query involving the same metadata object. The competing locks could lead to the deadlock detection logic victimizing the user action rather than the background sync Fix: ---- Change all exclusive metadata lock acquisition attempts during auto sync to use a try lock strategy with a timeout of 0 in place of the erstwhile 10 seconds. This avoids deadlock detection and gives higher priority to the user action Change-Id: I2e6eb4d2f87a5a253a7c6ff68a6fe0bda3dd6acb
1 parent 2b29da3 commit ed96b25

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

storage/ndb/plugin/ndb_metadata_sync.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ bool Ndb_metadata_sync::sync_logfile_group(THD *thd,
450450
const std::string &lfg_name,
451451
bool &temp_error) const {
452452
Ndb_dd_client dd_client(thd);
453-
if (!dd_client.mdl_lock_logfile_group_exclusive(lfg_name.c_str(), true, 10)) {
453+
if (!dd_client.mdl_lock_logfile_group_exclusive(lfg_name.c_str(), true)) {
454454
ndb_log_info("Failed to acquire MDL on logfile group '%s'",
455455
lfg_name.c_str());
456456
temp_error = true;
@@ -533,7 +533,7 @@ bool Ndb_metadata_sync::sync_logfile_group(THD *thd,
533533
bool Ndb_metadata_sync::sync_tablespace(THD *thd, const std::string &ts_name,
534534
bool &temp_error) const {
535535
Ndb_dd_client dd_client(thd);
536-
if (!dd_client.mdl_lock_tablespace_exclusive(ts_name.c_str(), true, 10)) {
536+
if (!dd_client.mdl_lock_tablespace_exclusive(ts_name.c_str(), true)) {
537537
ndb_log_info("Failed to acquire MDL on tablespace '%s'", ts_name.c_str());
538538
temp_error = true;
539539
// Since it's a temporary error, the THD conditions should be cleared but
@@ -618,10 +618,10 @@ bool Ndb_metadata_sync::sync_schema(THD *thd, const std::string &schema_name,
618618
// Acquire exclusive MDL on the schema upfront. Note that this isn't strictly
619619
// necessary since the Ndb_local_connection is used further down the function.
620620
// But the binlog thread shouldn't stall while waiting for the MDL to be
621-
// acquired. Thus, there's an attempt to lock the schema with a low
622-
// lock_wait_timeout value to ensure that the binlog thread can bail out early
621+
// acquired. Thus, there's an attempt to lock the schema with
622+
// lock_wait_timeout = 0 to ensure that the binlog thread can bail out early
623623
// should there be any conflicting locks
624-
if (!dd_client.mdl_lock_schema_exclusive(schema_name.c_str(), true, 10)) {
624+
if (!dd_client.mdl_lock_schema_exclusive(schema_name.c_str(), true)) {
625625
ndb_log_info("Failed to acquire MDL on schema '%s'", schema_name.c_str());
626626
temp_error = true;
627627
// Since it's a temporary error, the THD conditions should be cleared but
@@ -708,7 +708,7 @@ bool Ndb_metadata_sync::sync_table(THD *thd, const std::string &schema_name,
708708
}
709709
Ndb_dd_client dd_client(thd);
710710
if (!dd_client.mdl_locks_acquire_exclusive(schema_name.c_str(),
711-
table_name.c_str(), true, 10)) {
711+
table_name.c_str(), true)) {
712712
ndb_log_info("Failed to acquire MDL on table '%s.%s'", schema_name.c_str(),
713713
table_name.c_str());
714714
temp_error = true;

0 commit comments

Comments
 (0)