Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Lock] MySQL non-expiring locking using GET_LOCK #45251

Closed
@rtek

Description

@rtek

Description

The existing PDO lock store requires expiration to prevent stalled locks following unexpected termination. The Postgres store offers this feature, but there is not a MySQL equivalent.

Are the locking functions in mysql a viable solution? I see a problem with certain binlog_format settings. There shouldn't be an issue if the locks are assumed against the master.

Is this possible?

Example

Before

$store = new PdoStore(...);
$factory = ...
$lock = $factory->getLock('foo', 300.0);

$bar = 'baz';
while (true) {
   $bar .= $bar.$bar;
   $lock->refresh();
}
// stalled out for 300s

After

$store = new MySqlStore(...);
$factory = ...
$lock = $factory->getLock('foo');

$bar = 'baz';
while (true) {
   $bar .= $bar.$bar;
   $lock->refresh();
}
// lock released when mysql connection dies

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions