MySQL Forums
Forum List  »  NDB clusters

Re: GET_LOCK in ndb clusters
Posted by: Pete Ditmars
Date: October 20, 2021 06:45AM

Thanks Frazer for the reply.

We did (also) implement some simple "user-defined" lock/lease concepts in a regular table that has as a primary key the id of the "named lock", and it's good to hear that the insert/update/delete will serialize properly. (We just also liked some of the features of GET_LOCK in some other areas... the user-defined lock/lease concept is not as powerful.)

I just want to be doubly sure about what the below guidance from Mikael means

----
locks in NDB is currently best performed on application level using a row
per table to be lockable and ensuring that all applications start
by either performing LOCK IN READ MODE to get a shared lock or
LOCK IN EXCLUSIVE MODE to get an exclusive lock on the table.
----

So, if I have a table like this:

----
mysql> describe object_lock;
+------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| id | varchar(500) | NO | PRI | NULL | |
| requestId | varchar(255) | YES | | NULL | |
| startTime | datetime | YES | | NULL | |
| updateTime | datetime | YES | | NULL | |
| idleSecondsLimit | int | YES | | NULL | |
----

and just do normal
"INSERT INTO object_lock ..."
"UPDATE object_lock ... where id = ..."
"DELETE FROM object_lock .. where id = ..."

Then the ndb storage engine will take exclusive locks on the affected rows and the behaviors will be as expected even with clients operating simultaneously across the ndb cluster attached to multiple mysqld processes.

I just want to be sure about where the LOCK IN READ MODE and LOCK IN EXCLUSIVE MODE Mikael mentioned factors in... because we're presently not specifying these.

Thanks Frazer and Mikael,

Pete

p.s. - I just cannot seem to reply to the correct reply... forgive the incorrect reply-nesting. :-)



Edited 1 time(s). Last edit at 10/20/2021 06:47AM by Pete Ditmars.

Options: ReplyQuote


Subject
Views
Written By
Posted
386
October 19, 2021 08:23AM
182
October 19, 2021 01:16PM
185
October 19, 2021 03:06PM
259
October 19, 2021 05:20PM
158
October 19, 2021 07:07PM
195
October 20, 2021 09:40AM
140
October 19, 2021 06:09PM
144
October 20, 2021 06:24AM
Re: GET_LOCK in ndb clusters
159
October 20, 2021 06:45AM
158
October 20, 2021 08:19AM
154
October 20, 2021 08:56AM
162
October 20, 2021 04:01AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.