pdsinterop / php-solid-server

Standalone Solid Server written in PHP by PDS Interop
https://pdsinterop.org/php-solid-server/
MIT License
46 stars 7 forks source link

semaphore / concurrency #54

Open michielbdejong opened 2 years ago

michielbdejong commented 2 years ago

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 commented 2 years ago

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

Potherca commented 2 years ago

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 commented 2 years ago

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...