hieuhtr / Blog

Don’t be lazy. Don’t make excuses. No one cares. Work fucking harder.
Other
6 stars 2 forks source link

MySQL: FLUSH TABLES WITH READ LOCK #8

Open hieuhtr opened 7 years ago

hieuhtr commented 7 years ago

What is FLUSH TABLES WITH READ LOCK in MySQL?

Command:

mysql> FLUSH TABLES WITH READ LOCK;

What exactly does command do?

  1. Set the global read lock - after this step, insert/update/delete/replace/alter statements cannot run
  2. Close open tables - this step will block until all statements started previously have stopped
  3. Set a flag to block commits

It means:

Important:

Note:

How to unlock and keep MySQL back to normal?

zhjwpku commented 6 years ago

hi, I have one question,

FLUSH TABLES WITH READ LOCK does not prevent the server from inserting rows into the log tables

what are the log tables? binary log?

chandankumar4 commented 5 years ago

Hi I'm trying to take a snapshot so for this i run the command FLUSH TABLES WITH READ LOCK before taking snapshot but the issue is if i close the session where i run the flush command and start a new session then i'm able to write data in mysql DB, Is there any way like, after closing the session the flush command will persist and write is blocked until we run unlock tables cc @hieuhtr