List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 6 2001 3:39am
Subject:Re: mysqldump
View as plain text  
>Hi,
>
>I'm using mysqldump to backup my databases.  Does anyone know if mysqldump
>locks all the tables in the database prior to performing the dump?
>
>I ask this because if an update is in progress which inserts/modifies
>records in several tables, performing a mysqldump could backup the database
>in an inconsistent state (partial transaction).

If an update is in progess, there's an implicit write lock on the table,
so no client, including mysqldump, can read it until the update completes.

mysqldump has a --lock-tables option, but what this does is put an
explicit read lock on every table that it's going to dump before it
dumps any of them, then unlocks them all.  If you do this for an entire
database, that effectively prevents any updates on any tables for
the duration of the dump.  (Other clients can read during the update,
because read locks don't block other readers.)

>
>Thanks,
>Don

-- 
Paul DuBois, paul@stripped
Thread
mysqldumpDon6 Jun
Re: mysqldumpPaul DuBois6 Jun