charmbracelet / skate

A personal key value store 🛼
MIT License
1.28k stars 23 forks source link

Key/Value inconsistency when setting values from two different hosts #82

Open mbentley opened 6 months ago

mbentley commented 6 months ago

I am not sure if I am doing something unexpected but I have two clients and a self-hosted charm server. Everything seems to work as expected when I am only using one client but when I introduce a second client, things start to get out of sync if I initially set a value from one client and then later try to update the same key from the other. I am assuming that this workflow should work and I don't see why there would be a difference between using one client or many:

  1. Host 1 sets the value of foo to bar and list k/v to show it:

    $ skate set foo bar
    $ skate list
    foo     bar
  2. Host 2 checks the k/v:

    $ skate list
    foo     bar
  3. Host 2 changes the value of foo to bar2:

    $ skate set foo bar2
    $ skate list
    foo     bar2
  4. Host 1 performs a sync and then checks the list which should now show the updated value but doesn't:

    $ skate sync
    $ skate list
    foo     bar

At this point, host 1 and host 2 are out of sync. If I perform a skate reset on both hosts, they both revert back to foo bar as the k/v.

I can see host 2 updating on the server side so I do not know why it seems to be out of sync and unable to be reconciled:

2023/12/31 19:16:06 <- POST /v1/fs/0777674bff03172294f90d5508e44052b9a175a040462fb6e567f5ddc00c9b66f2ea7737dcde/9aabe1cfed5709b1190d1910b41f302d7a4f?mode=432 192.168.0.150

My apologies that this isn't the best example and that I don't have much else in the way of logs but I am not really sure what will be helpful from a troubleshooting standpoint.

It seems that if I do a delete and then a set, the updates work as expected so it seems that just doing a set when there is an existing key value set does not work as I would expect to just update the value.

flippedcracker commented 3 months ago

I'm seeing the same issue.

HoboDev commented 3 weeks ago

You should be able to circumvent this by deleting the key first and then setting it again with the new value. It's a bit nasty but seems to work.