hyperdrive icon indicating copy to clipboard operation
hyperdrive copied to clipboard

Multiple device-local writers

Open pfrazee opened this issue 8 years ago • 0 comments

Using https://github.com/joehand/dat-secret-storage, @joehand and I have been conspiring to share private key storage between Beaker and Dat CLI. That would be really handy for me, because then I could create a Dat in the CLI, then make changes within Beaker.

But! It looks like this creates a coordination problem of multiple writers. What we dont want to happen is have conflicting writes issued by Beaker and Dat-CLI.

Fortunately, it's not a distributed multiwriter situation, so I think we can solve it pretty simply:

  1. Add a lockfile to the centralized storage.
  2. Also store the current metadata seq number in centralized storage.
  3. Only allow writes if you can 1) acquire the lock, and 2) have the most recent files synced.

That said, we can easily run into edgecase problems. Suppose I start dat-cli, make updates to a pre-existing shared dat, close dat-cli, and then open Beaker. Beaker will never sync the recent changes, but it also wont be able to make updates on account of the metadata seq. Worse: what if the user deletes the dat-cli copy of the dat, and thus can never update the Beaker copy?

pfrazee avatar Apr 14 '17 02:04 pfrazee