thesecretmaster / predis-v0

Like redis, but parallel and written from scratch for fun!
GNU General Public License v3.0
1 stars 0 forks source link

Support updates #2

Closed thesecretmaster closed 5 years ago

thesecretmaster commented 5 years ago

Currently, predis only supports adding elements and deleting them. Since it currently only stores integers, that's not much of a problem, but as it grows to support more and more types, we'll want to be able to do updates. For example, if we had a set type, we'd want to be able to add and remove elements.

thesecretmaster commented 5 years ago

Still need a update method in lib.c, unsure how that'll look.

thesecretmaster commented 5 years ago

Whenever this gets done, we'll also want some tests of concurrent operations on the same keys. We'll also want to have about look at the sketchy per-thread safe global -- that really needs to either be mixed in to main_struct->thread_info or really, I'm not sure if it serves it's purpose. The intention is to confirm that all threads are in a "safe" place so that deleted elements can be freed by clean_queue -- to prevent the following sequence:

  1. thread A starts a get at index 11, then sleeps before the get completes
  2. thread B runs a del on index 11, then runs clean_queue (which frees the value at index 11)
  3. thread A wakes up, thinks it's operating on a good element, and reads from freed memory

With safe, ideally it would be set to false in 1, so thread B would block until each thread has reached a safe state at least once, then it would actually clean the queue. This would make thread B block until after A wakes up and completes the operation (and sets safe back to true)