| Bug #72887 | LOCK TABLES uses incorrect lock for implicitly used tables | ||
|---|---|---|---|
| Submitted: | 5 Jun 2014 12:07 | Modified: | 27 Oct 2014 17:39 |
| Reporter: | Dmitry Lenev | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Locking | Severity: | S3 (Non-critical) |
| Version: | 5.6.17-bzr | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[5 Jun 2014 12:07]
Dmitry Lenev
[27 Oct 2014 17:39]
Paul DuBois
Noted in 5.6.22, 5.7.6 changelogs. LOCK TABLES sometimes acquired an insufficiently strong lock for implicitly locked tables.
[10 Dec 2014 14:13]
Laurynas Biveinis
$ bzr log -r 6218
------------------------------------------------------------
revno: 6218
committer: Praveenkumar Hulakund <praveenkumar.hulakund@oracle.com>
branch nick: mysql-5.6
timestamp: Fri 2014-10-24 23:38:40 +0530
message:
Bug#18913551 : LOCK TABLES USES INCORRECT LOCK FOR IMPLICITLY
USED TABLES.
Analysis:
----------
Issue here is, LOCK table operation sometime acquired too weaker
lock on the tables locked implicitly.
LOCK TABLE on a view which uses stored function which uses some
table acquires lock TL_READ on that table. As result, such
LOCK TABLE operation allows concurrent insert on the table
used by function. And this can break statement based replication/
cause wrong binlog order.
While opening tables used in a statement, tables used in stored
functions(if statement uses any) are also opened and locked
implicitly. When statement based replication is on, if function
does not modify any data then the lock TL_READ acquired on such
user tables by ignoring prelocking_placeholder set for them in
function "read_lock_type_for_table". This helps in taking weaker
locks on such tables and allows concurrent insert operations on
them. But when opening tables for "LOCK TABLE" operations, because
of the above mentioned logic, lock type "TL_READ" is set instead
of "TL_READ_NO_INSERT" for tables of stored function which does
not modify any data. Hence issue mentioned in the report is seen.
Fix:
----------
In function "read_lock_type_for_table", when statement based
replication is on, for tables of stored functions lock_type
TL_READ_NO_INSERT is set for LOCK TABLE statement. Flag used to
indicate stored function modifies data or not is ignored in this
case.
