This is probably a really dumb question but I was just wondering if you set autocommit off for MySQL and then try to acquire a lock, do you have to then commit after getting the lock for the lock to stay?
$mysqli->autocommit(FALSE);
$q = 'SELECT GET_LOCK("lockName", 10)';
$res = $mysqli->query($q);
list($acquiredLock) = $res->fetch_row();
if($acquiredLock) {
$mysqli->commit();
}
Thank you for your kind help.
No. If GET_LOCK
returns 1 (success), then the session has obtained the lock.
The lock will continue to be held by the session independent of COMMIT
or ROLLBACK
.