Repository navigation
Database backend for locking - #17662
Conversation
There was a problem hiding this comment.
I didn't know that I already contributed to this new file ;)
There was a problem hiding this comment.
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 ....
|
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 |
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) |
|
Rebased
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 |
There was a problem hiding this comment.
meanwhile we renamed to "transactional file locking" 😄
|
Apart from the few comments, the code looks good. |
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 |
|
Should we auto-delete remaining keys after unlocking ? This appears and I don't have any running operation. |
|
Ran |
|
Tested locking with sleep() and it seems to work fine
|
|
@icewind1991 can you please take care about the remaining open points? |
|
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) |
|
In any way a performance impact might be preferable to losing data in concurrency cases. At least as a default setting. |
|
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. |
|
@icewind1991 can you move the lock cleanup to a cron job ? |
let's do this in a separate PR ... |
|
Fine by me 👍 |
|
|
Needs a second reviewer @DeepDiver1975 @nickvergessen @Xenopathic |
There was a problem hiding this comment.
we need to add the path at least - otherwise the log entry is pointless
|
A new inspection was created. |
|
👍 |
Database backend for locking

Adds a database backend for locking.
cc @DeepDiver1975 @PVince81