Skip to content

Database backend for locking - #17662

Merged
DeepDiver1975 merged 12 commits into
masterfrom
locking-db
Aug 26, 2015
Merged

DeepDiver1975 merged 12 commits into
masterfrom
locking-db

Conversation

@icewind1991

Copy link
Copy Markdown
Contributor

Adds a database backend for locking.

cc @DeepDiver1975 @PVince81

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't know that I already contributed to this new file ;)

@MorrisJobke MorrisJobke added this to the 8.2-current milestone Jul 15, 2015
Comment thread db_structure.xml Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

afaik we already had a table named locks some versions back ... in addition there is a repairstep which cleans old tables. We better double check ....

@DeepDiver1975

Copy link
Copy Markdown
Contributor

So - does this db based locking properly work in case this is done with in a transaction?

From my understanding we can still run into runtime issues on this.

@nickvergessen which smashbox test can be used to test locking - is there something in place already? THX

@ghost

ghost commented Jul 21, 2015

Copy link
Copy Markdown

🚀 Test PASSed.🚀
chuck

@nickvergessen

Copy link
Copy Markdown
Contributor

@nickvergessen which smashbox test can be used to test locking - is there something in place already? THX

Well all current tests are good to test, especially uploadFiles and concurrent(Dir(Re)move|OverwriteFile)

More locking related tests are in a branch owncloud/smashbox#107 (still waiting for cernbox to merge our last two PRs so we can rebase and reset our repo, then we can have them in our repo)

@icewind1991

Copy link
Copy Markdown
Contributor Author

Rebased

So - does this db based locking properly work in case this is done with in a transaction?

Transactions would interact with the locking if we open/close a lock from within a transaction, afaik all the places where we currently do transactions (mostly for batching cache updates) are fine since the lock management is done outside of the transaction

Comment thread db_structure.xml Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

meanwhile we renamed to "transactional file locking" 😄

@PVince81

PVince81 commented Aug 3, 2015

Copy link
Copy Markdown
Contributor

Apart from the few comments, the code looks good.
Will test later.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

are fine since the lock management is done outside of the transaction

Can we somehow add a check to make sure this is the case under any curcumstance - I'm pretty sure we will not remember this requirement in the future

@PVince81

PVince81 commented Aug 6, 2015

Copy link
Copy Markdown
Contributor

Should we auto-delete remaining keys after unlocking ?

MariaDB [owncloud]> select * from oc_file_locks;
+----+------+----------------------------------------+-----+
| id | lock | key                                    | ttl |
+----+------+----------------------------------------+-----+
|  1 |    0 | files/2a2694688f159d7d04bd51bd0534851f |   0 |
+----+------+----------------------------------------+-----+

This appears and I don't have any running operation.

@PVince81

PVince81 commented Aug 6, 2015

Copy link
Copy Markdown
Contributor

Ran bin/smash -a lib/oc-tests/new_locking on the locking_tests branch: no errors.

@PVince81

PVince81 commented Aug 6, 2015

Copy link
Copy Markdown
Contributor

Tested locking with sleep() and it seems to work fine

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@icewind1991 can you please take care about the remaining open points?
I'd like to get this merged asap - THX

@icewind1991

Copy link
Copy Markdown
Contributor Author

Added cleanup for empty locks and it now logs a warning while trying to acquire a lock from within a transaction.

From playing around with it a bit it seems that it happens during file scanning, I dont think that will cause issues but we need to take that into account.

Also note that using the db as a locking backend has a significant performance impact (comparison)
The performance impact of redis based locking is non-detectable on my setup but that might be different for larger setups

@PVince81

Copy link
Copy Markdown
Contributor

In any way a performance impact might be preferable to losing data in concurrency cases. At least as a default setting.

@PVince81

Copy link
Copy Markdown
Contributor

The locks are now properly cleant up.

What if there are 1000 concurrent requests that try and clean up the same empty locks at the same time, will this give DB transaction timeouts ? I ask this because I see that the cleanup is done in the destructor at the end of a PHP request. We could also move this to a cron job instead to avoid overloading the DB.

@ghost

ghost commented Aug 10, 2015

Copy link
Copy Markdown

🚀 Test PASSed.🚀
chuck

@PVince81

Copy link
Copy Markdown
Contributor

@icewind1991 can you move the lock cleanup to a cron job ?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@icewind1991 can you move the lock cleanup to a cron job ?

let's do this in a separate PR ...

@PVince81

Copy link
Copy Markdown
Contributor

Fine by me 👍

@PVince81

Copy link
Copy Markdown
Contributor
  • TODO: move lock cleanup to a cron job in a separate PR <- @icewind1991

@PVince81

Copy link
Copy Markdown
Contributor

Needs a second reviewer @DeepDiver1975 @nickvergessen @Xenopathic

Comment thread lib/private/lock/dblockingprovider.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we need to add the path at least - otherwise the log entry is pointless

@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@ghost

ghost commented Aug 25, 2015

Copy link
Copy Markdown

🚀 Test PASSed.🚀
chuck

@DeepDiver1975

Copy link
Copy Markdown
Contributor

👍

DeepDiver1975 added a commit that referenced this pull request Aug 26, 2015
@DeepDiver1975
DeepDiver1975 merged commit 534b2e4 into master Aug 26, 2015
@DeepDiver1975
DeepDiver1975 deleted the locking-db branch August 26, 2015 01:56
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants