antonioribeiro / health

Laravel Health Panel
BSD 3-Clause "New" or "Revised" License
1.95k stars 197 forks source link

CloudStorage checker can get false-negative related to eventual consistency (needs less invasive method, too?) #138

Open worldofswift opened 5 years ago

worldofswift commented 5 years ago

Given PragmaRX\Health\Checkers\CloudStorage:

The logic of checker is straightforward:

  1. We put the new file to the disk
  2. We check it existence
  3. We delete it

For local filesystems, it will work fine, but for example s3 it is undesired order of actions:

  1. S3 guarantees consistency for newly created objects.
  2. But for deletes and overwrites with PUT, it doesn't guarantee it. (I don't remember the actual timings).
  3. As a result, we can get into a situation with consequential checks - in the previous one we just deleted an object, in current we add a new object with the same name and it actually considered as overriding, so now it is possible to get file not found exception during an attempt to get content from that file (new version hasn't propagated yet to replace deleted one).

    Please note, that the delete action is not a key here - it is similar to PUT request.

So, this checker is inappropriate for S3 with short grace.

Possible workaround:

  1. Force to not using constant strings as the file name
  2. Add some small hash (maybe 4 letters UUID will be good enough) internally to the value of filename in the checker.