Bug #31352 | Write locking in stored functions with INSERT and SELECT statemenst | ||
---|---|---|---|
Submitted: | 2 Oct 2007 18:55 | Modified: | 20 Oct 2007 16:17 |
Reporter: | Adam Miel | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Locking | Severity: | S3 (Non-critical) |
Version: | 5.0.45 | OS: | Any (Linux, Windows) |
Assigned to: | CPU Architecture: | Any | |
Tags: | myisam, Stored Functions |
[2 Oct 2007 18:55]
Adam Miel
[16 Oct 2007 13:25]
Sveta Smirnova
Thank you for the report. Verified as described.
[19 Oct 2007 20:17]
Konstantin Osipov
This is a limitation of pre-locking that should be clarified in the documentation. When a stored function or trigger is used, pre-locking algorithm takes the most conservative lock on the table that may be required to execute the trigger/function. In the example above the function needs TL_READ and TL_CONCURRENT_INSRT locks on the table, so TL_CONCURRENT_INSERT lock is acquired. Note, it is acquired at start of statement, no lock upgrades are performed when the statement is running. Two TL_CONCURRENT_INSERT locks are incompatible with each other, and thus the second SELECT blocks. InnoDB does not expose this behavior since it downgrades all table level locks to TL_WRITE_ALLOW_WRITE.
[20 Oct 2007 16:17]
Adam Miel
Understand, sorry I didn't know that concurrent inserts are locking Tahank you