| Bug #110243 | Suggest to add get_reader_lock/get_writer_lock for locking functions | ||
|---|---|---|---|
| Submitted: | 1 Mar 2023 0:35 | Modified: | 1 Mar 2023 4:27 |
| Reporter: | Fangxin Flou (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Locking | Severity: | S4 (Feature request) |
| Version: | all, 8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | GET_LOCK | ||
[1 Mar 2023 0:35]
Fangxin Flou
[1 Mar 2023 4:27]
MySQL Verification Team
Hello Fangxin Flou, Thank you for the feature request! regards, Umesh
[2 Mar 2023 9:28]
Jakub Lopuszanski
Hi! Depending on use case, and if the set of lock "names" is finite, then you can create a `locks` table with one row per "lock", and with the `name` being the primary key of the table. Then you can request write/exclusive access with: BEGIN;SELECT 1 FROM locks WHERE `name`="abc" FOR UPDATE; or read/shared access with: BEGIN; SELECT 1 FROM locks WHERE `name`="abc" FOR SHARE; you can even use `innodb_lock_wait_timeout` per sesssion to implement "timed wait". Can you describe your use case in sufficient detail so that it is clear why above scheme would not work?
