php-solid-server icon indicating copy to clipboard operation
php-solid-server copied to clipboard

semaphore / concurrency

Open michielbdejong opened this issue 4 years ago • 3 comments

php-solid-server is failing the new concurrency tests that were added in solid-crud-tests v5.1.0.

What these tests do is send 10 PUT requests for the same resource at the same time, with If-None-Match: * header. This means only 1 of them should return a 201 and the other 9 should return 412 Precondition Failed.

Looking at the code, it does a has check first and then a write. Does FlySystem support something like an atomic WriteIfNotExists or something like Lock?

michielbdejong avatar Nov 24 '21 13:11 michielbdejong

Hm, doesn't seem like it does - https://github.com/thephpleague/flysystem/search?q=atomic&type=issues

michielbdejong avatar Nov 24 '21 13:11 michielbdejong

There is the ability to use locks with the Local adapter which is what we currently use.

That might cause problems later, if/when we ever decide to (also?) support other adapters, but for now it should not cause trouble...

Hmmm... It says "By default this adapter uses a lock during writes and updates", which means that's not what we're looking for.

Potherca avatar Nov 25 '21 15:11 Potherca

Looks like we are still using FlySystem v1, which does seem to have a put method. In v2, this has been changed to deterministic writes. We might be able to change the logic as to not use has and allow FlySystem to handle the fallout? :thinking: Still feel like I'm missing something, though...

Potherca avatar Nov 25 '21 15:11 Potherca