In order to better optimize MySQL in high concurrency, it is necessary to understand the locking table mechanism when MySQL query is updated.I. OverviewMySQL has three levels of Lock: page level, table level, row level.The MyISAM and memory storage
Xtrabackup is used in a project to back up the MySQL database. The DDL statement with two exceptions was executed too long, causing the flush table with read lock lock to be unable to be released when the morning backup. Subsequent additions and
FLUSH TABLES with READ lock abbreviation (FTWRL), which is used primarily for backup tools to obtain a consistent backup (the data matches the Binlog bit). since FTWRL requires a total of two global MDL locks, and all table objects need to be closed,
Today, the flush tables with read lock command was used to solve Database Synchronization exceptions, so I learned about the lock table by the way.
1. FLUSH TABLES WITH READ LOCK
This command is global read lock. After the command is executed, all
SolutionsFailure summaryThe global read lock in the system was acquired by another thread (with an S lock), so DML will appear waiting for global read lock on the GRL with IX lock, and the set READ_ONLY is the S lock on GRL, So at this point it is
1.FLUSH TABLES with READ LOCKThis command is a global read lock, and all of the library tables are locked for read-only after the command has been executed. is generally used in the database online backup, this time the database write operations
A shared lock (S lock) is also called a read lock, and if the transaction T is a plus s lock on the data object A, the transaction T can read a but cannot modify a, and the other transaction can only have a plus s lock, not the x lock, until T
Why cannot I query the data after a read lock is applied to the table? Mysql_query ("LOCK & nbsp; TABLES & nbsp; tablename & nbsp; READ;"); $ result = mysql_query ($ SQL, & nbsp; $ conn ); mysql_query ("UNLOCK & nbsp; TABLES;"); comment out why data
Read Lock: All sessions can only be queried by the SELECT statementTABLE [table_name] READSELECT * FROM table_name;INSERT into table_name () VALUES (); #一直等待, until unlocked or timed outWrite Lock: only the current session can be added and checked,
MySQL official manual read lock instructionsIf, in the same transaction, you query the data and insert/Update data related to this data, the usual SELECT statement will not give us enough protection. Because in the time period between the Select and
The set global read_only is a global level and can be written by the root user after 1, and other users cannot write FLUSH tables with read lock is table-level (using unlock tables to unlock) and cannot be written by all users after execution. But
Read/write locks in Java concurrent packages and their Implementation Analysis
1. Preface
Usually used locks such as ReentrantLock in Java concurrent packages are usually exclusive locks. These locks can be accessed by only one thread at a time,
Basic Introduction:
Read and write Lock: ReadwritelockIn a multi-threaded environment, reading and writing to the same data will involve thread-safety issues. For example, when one thread reads the data, another thread writes the data, which
Java5 already contains a read-write lock in the Java.util.concurrent package. Still, we should understand the rationale behind its implementation.
Java implementation of read/write locks (Read/write lock Java Implementation)
Read/write
Reentrantlock are exclusive locks that allow only one thread to access at the same time, while read-write locks allow multiple threads to access at the same time, but all read and other write threads are blocked while the write thread is accessing.
Reentrantreadwritelock-based AQS implementation of read-write lock synchronization:1. Using the shared mode to achieve read lock, exclusive mode to achieve write lock;2. Support for fair and non-fair, non-fair situations where a read lock blocking
In order to better optimize MySQL in high concurrency, it is necessary to understand the locking table mechanism when MySQL query is updated.I. OverviewMySQL has three levels of Lock: page level, table level, row level.MyISAM and MemoryStorageThe
In the case of high concurrency, when using the Ehcache cache, the data we read may be wrong due to concurrent reads and writes, and the data we write may be accidentally overwritten. Fortunately, Ehcache provided us with a read (read)/write (write)
1. What is read and write lock
It is possible to allow multiple read threads to access at the same time, or locks that are blocked by all read threads and other write threads when the write thread is accessed. Read-write lock in two, divided into a
Java multithreading-read/write locks and java Multithreading
Java 5 contains the read/write lock in the java. util. concurrent package. Even so, we should understand the principles behind its implementation.Java Implementation of read/write
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.