0

I am running Fedora 42 KDE spin, and the output from mysql -V is

mysql Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using EditLine wrapper

I have a script that runs weekly that creates a large data table and then runs various other scripts to generate various reports. One of the reports is a union of a few selects which involve joins. While those joins were running, I opened another terminal and, without thinking, fired off a maintenance script which removes duplicates and then drops the non-unique index and builds a primary key in the large table. My question is, what did that do to the first job (running the joins)? Will Maria lock the index during the join and therefore not drop it until after the first job completes? Will the first job complete correctly but much much more slowly? Is there any defensive coding I can add to either or both scripts that would protect against user stupidity like this?

1
  • If MariaDB doesn't protect against usual user behaviour (stupidity is excessively harsh :-) ), its MariaDB's job to handle it and you can write a bug if you observe a lack of protection. In this case however, its handled already and pretty standard. Commented Sep 2 at 6:36

1 Answer 1

5

The answer is easily found in the documentation:

If another connection is using the table, a metadata lock is active, and this statement1 will wait until the lock is released.


1 - "This statement" being ALTER TABLE, which is the same as CREATE INDEX and DROP INDEX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.