Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(other): db session locking to support exclusive mode #1380

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Shadow243
Copy link
Member

Related task item89272

@Shadow243 Shadow243 requested a review from kroky November 23, 2024 03:55
@Shadow243 Shadow243 changed the title Revamp db session storage to work in exclusive locking mode like nati… Fix: Revamp db session storage to work in exclusive locking mode like nati… Nov 23, 2024
@Shadow243 Shadow243 changed the title Fix: Revamp db session storage to work in exclusive locking mode like nati… fix: Revamp db session storage to work in exclusive locking mode like nati… Nov 23, 2024
@Shadow243 Shadow243 changed the title fix: Revamp db session storage to work in exclusive locking mode like nati… refactor(session): refactor db session locking to support exclusive mode Nov 23, 2024
@Shadow243 Shadow243 changed the title refactor(session): refactor db session locking to support exclusive mode refactor(other): refactor db session locking to support exclusive mode Nov 23, 2024
switch ($this->db_driver) {
case 'mysql':
$query = 'SELECT GET_LOCK(:lock_name, :timeout)';
$params = [':lock_name' => $lock_name, ':timeout' => $this->lock_timeout];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should implement the lock_timeout in other drivers as well - this is important for concurrent requests. You can use a polling mechanism with intervals of 500ms to 1 second.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kroky I just updated, I just did a test with mysql. I'm waiting to see if there are any corrections from you so far before confirming with pgsql too but it should work for pgsql too

$stmt = "{$create_table} hm_user_session (hm_id varchar(255), data longblob, date timestamp, primary key (hm_id));";
} elseif($db_driver == 'sqlite') {
//0 means unlocked, 1 means locked
$stmt = "{$create_table} hm_user_session (hm_id varchar(255), data longblob, lock INTEGER DEFAULT 0, date timestamp, primary key (hm_id));";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would existing users update their databases? I think we should introduce some kind of a migration mechanism or handle this in the code.

@Shadow243 Shadow243 changed the title refactor(other): refactor db session locking to support exclusive mode refactor(other): db session locking to support exclusive mode Nov 29, 2024
@Shadow243 Shadow243 force-pushed the revamp-db-session-storage branch 14 times, most recently from 4f0632b to 066c003 Compare November 29, 2024 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants