about summary refs log tree commit diff
path: root/kittybox-rs/templates/src/onboarding.rs
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-05-01 04:35:16 +0300
committerVika <vika@fireburn.ru>2022-05-01 04:35:16 +0300
commit122361795b3b1376c6ba03ed6b160e9b89da93d7 (patch)
tree71fe8dc080a74952c29da04d57689c2643e7f211 /kittybox-rs/templates/src/onboarding.rs
parente2bc26e907c10def259f52401804f7f6d00c498c (diff)
downloadkittybox-122361795b3b1376c6ba03ed6b160e9b89da93d7.tar.zst
FileStorage: lockless reads and atomic writes
  - Reads don't lock anymore. At all.
  - Writes create a temporary file and use `rename(2)` to atomically
    replace it
  - since OpenOptions::create_new(true) is used, tempfile creation is
    atomic (and since tempfile names are per-post, a post can only be
    edited by one request at a time)
  - Since written files get atomically replaced, readers can't read a
    corrupted file

Potential pitfalls:
1. This approach is not covered by unit tests (yet)
2. Stale tempfiles can prevent editing posts (can be solved by
throwing out tempfiles that are older than, say, a day)
3. Crashed edits can leave stale tempfiles (honestly that sounds
better than corrupting the whole database, doesn't sound like a bug to
me at all!)
Diffstat (limited to 'kittybox-rs/templates/src/onboarding.rs')
0 files changed, 0 insertions, 0 deletions