Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open metadata lock #41796

Closed
jiyfhust opened this issue Mar 1, 2023 · 2 comments · Fixed by #41913
Closed

Can't open metadata lock #41796

jiyfhust opened this issue Mar 1, 2023 · 2 comments · Fixed by #41913
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@jiyfhust
Copy link
Contributor

jiyfhust commented Mar 1, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> show global variables like "%tidb_enable_metadata_lock%";
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| tidb_enable_metadata_lock | ON    |
+---------------------------+-------+
1 row in set (0.00 sec)

mysql> set global tidb_enable_metadata_lock=0;
Query OK, 0 rows affected (0.15 sec)

mysql> show global variables like "%tidb_enable_metadata_lock%";
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| tidb_enable_metadata_lock | OFF   |
+---------------------------+-------+
1 row in set (0.00 sec)

mysql> set global tidb_enable_metadata_lock=1;
Query OK, 0 rows affected (0.02 sec)

mysql> show global variables like "%tidb_enable_metadata_lock%";
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| tidb_enable_metadata_lock | OFF   |
+---------------------------+-------+
1 row in set (0.00 sec)

2. What did you expect to see? (Required)


mysql> set global tidb_enable_metadata_lock=1;
Query OK, 0 rows affected (0.02 sec)


mysql> show global variables like "%tidb_enable_metadata_lock%";
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| tidb_enable_metadata_lock | ON    |
+---------------------------+-------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

Is it the reason for the problem?

tidb/ddl/ddl.go

Line 1247 in 96e345d

if enable {


	if enable {
		sql := fmt.Sprintf("UPDATE HIGH_PRIORITY %[1]s.%[2]s SET VARIABLE_VALUE = %[4]d WHERE VARIABLE_NAME = '%[3]s'",
			mysql.SystemDB, mysql.GlobalVariablesTable, variable.TiDBEnableMDL, 0)
		sess, err := d.sessPool.get()
		if err != nil {
			logutil.BgLogger().Warn("[ddl] get session failed", zap.Error(err))
			return nil
		}
		defer d.sessPool.put(sess)
		se := newSession(sess)
		_, err = se.execute(ctx, sql, "disableMDL")
		if err != nil {
			logutil.BgLogger().Warn("[ddl] disable MDL failed", zap.Error(err))
		}
		return nil
	}

4. What is your TiDB version? (Required)


mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.6.0
Edition: Community
Git Commit Hash: f4ca0821fb96a2bdd37d2fb97eb26c07fc58d4e4
Git Branch: heads/refs/tags/v6.6.0
UTC Build Time: 2023-02-17 14:49:02
GoVersion: go1.19.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)

@jiyfhust jiyfhust added the type/bug The issue is confirmed as a bug. label Mar 1, 2023
@wjhuang2016
Copy link
Member

wjhuang2016 commented Mar 3, 2023

Thanks for reporting this bug, it was introduced by PR

@jiyfhust
Copy link
Contributor Author

jiyfhust commented Mar 3, 2023

@wjhuang2016 It seems remove the code can fix it?
Need i make a pull request for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants