Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Improve how page handling is done #29

Closed
chotchki opened this issue Sep 26, 2021 · 1 comment · Fixed by #30
Closed

Improve how page handling is done #29

chotchki opened this issue Sep 26, 2021 · 1 comment · Fixed by #30

Comments

@chotchki
Copy link
Owner

Currently all pages in the system are being handled via Tokio's BytesMut struct and related traits. This struct is awesome for giving me easy read/write methods on an underlying set of pointers.

However I have discovered a critical issue that I am uncertain how to solve effectively.

So right now I have a combination of features in my lock/cache system:

  • Reader/Writer locks for a given page
  • A least recently used cache of pages
  • A way to check out pages and if discarded a way to purge the cache.

The issue I am facing is as follows:

  1. A page is is checked out for read or write.
  2. Read/writes are done to it but are discarded for any number of reasons.
  3. The next process checks out the same page.
  4. The process will not see the entire page since it has been consumed partially. This leads to interesting and painful bugs as I discovered in my index work.
@chotchki
Copy link
Owner Author

Possible Fix:

  • Right now the lock/cache layer provides RwLocks over a BytesMut based on a requested (PageId, PageOffset). This does cause pain due to a split between reads and writes. I did this because its trivial to replace the contents of a page without extra allocations. However I don't think I can get away with that any more.
  • Instead I think I'll provide a RwLock over (PageId, PageOffset). That lock will determine if you can update the underlying buffer.

However I don't know how to make sure other queued users get the updated page.

@chotchki chotchki added this to To do in FeOphant MVP via automation Sep 26, 2021
@chotchki chotchki moved this from To do to In progress in FeOphant MVP Sep 26, 2021
FeOphant MVP automation moved this from In progress to Done Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant