HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

MySQL: Safe to kill transaction that is stuck in "Waiting for table metadata lock"

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
killwaitingstuckmysqlthattransactionsafeformetadatatable

Problem

Good morning/afternoon/night.

I attempted to add a column to a table with a good few million rows. Here is the full query:

alter table date_tasks_mark add column noDuplicate int unsigned not null default 0


However it seems to be stuck.

| 28893 | root         | localhost | database_name   | Query   | 10668 | Waiting for table metadata lock | alter table date_tasks_marks add column noDuplicate int unsigned not null default 0


Is it safe for me to kill the query or will it corrupt my table (it has been in this state for about a half hour)?

Solution

Yes, it's safe. Your alter table query hasn't even started.

However, the waiting for table metadata lock means, that there's another transaction operating on that table for a long time and you should rather kill that one to solve the problem. (read more about it here: 8.11.4 Metadata Locking)

To find this transaction, this thread is probably helpful: How do I find which transaction is causing a “Waiting for table metadata lock” state?

Context

StackExchange Database Administrators Q#195018, answer score: 14

Revisions (0)

No revisions yet.