What does HackerNews think of cr-sqlite?

Convergent, Replicated SQLite. Multi-writer and CRDT support for SQLite

Language: C

#14 in Database
No, LiteFS just does physical page replication. We don't really have a way to do merge conflict resolution between two nodes. You may want to look at either vlcn[1] or Mycelite[2] as options for doing that approach.

[1]: https://github.com/vlcn-io/cr-sqlite

[2]: https://github.com/mycelial/mycelite

I haven't personally but typically people use a CRDT-based approach like vlcn[1] or Mycelite[2].

[1]: https://github.com/vlcn-io/cr-sqlite

[2]: https://github.com/mycelial/mycelite

Yes, Matt Tantaman wrote a SQLite extension that gives it CRDT semantics! It's a CRDT-Sqlite or ... CR-Sqlite. Ha.

https://github.com/vlcn-io/cr-sqlite

It's possible but very difficult. For extensions built purely in C, you can statically compile extensions into a SQLite WASM build, which I have a few demos of with sqlite-lines [0] and sqlite-path[1].

For extensions but in Rust however, it's much more difficult. Matt @tantaman has some success cross compiling his cr-sqlite [2] project to WASM, but it's quite complex.

SQLite extensions typical rely on dlopen() to load dynamic libraries as an extension. WASM doesn't really have that, so you either have to statically compile your extension in your WASM build (which is difficult for non-C languages bc SQLite is written in C), or hack around some barely-supported WASM features that emulate dlopen(). Though I'm not the best with WASM, so hopefully someone with more WASM experience chimes in to help! It's something I'm tracking in this issue for the `sqlite-loadble-rs` project [3]

[0] https://observablehq.com/@asg017/introducing-sqlite-lines#ce...

[1] https://observablehq.com/@asg017/introducing-sqlite-path#cel...

[2] https://github.com/vlcn-io/cr-sqlite

[3] https://github.com/asg017/sqlite-loadable-rs/issues/5

The problem is conflicts. If two remote peers both edit data concurrently, its not obvious what the resulting sqlite state should be.

Better to embed a CRDT inside sqlite that can understand the semantics of sqlite's data, like cr-sqlite is doing:

https://github.com/vlcn-io/cr-sqlite

There’s a free CRDT based SQLite sync system. It’s for a different use-case — local first software including peer to peer sync use-case.

https://github.com/vlcn-io/cr-sqlite

51 days ago: https://news.ycombinator.com/item?id=33606311

cr-sqlite is a similar project on SQLite, but it's a standalone extension without a web framework.

https://github.com/vlcn-io/cr-sqlite/

https://github.com/vlcn-io/cr-sqlite/

> Tables are modeled as GSets...

> Rows are currently modeled as LWW maps. I.e., each column in a row is a LWW Register.

Multi value registers are also planned - though I'm not sure how that'll be implemented.

(One also has the opportunity to see failing writes to the LWW register, so for my app I can (in theory) potentially surface those somewhere to the user as a resolvable conflict.)

All the CRDTs I'm looking at here are doing the work in memory only. Adding a good persistence layer is a big missing piece here.

But some people are working on adding CRDTs to sqlite: https://github.com/vlcn-io/cr-sqlite

It'd be really fun to see if this approach can be adapted to sqlite's b-tree. But it might not work as-is. The b-tree implementation I have is quite a bit different from most b-trees because I'm storing offsets rather than "keys", and because I'm storing compacted runs of items rather than individual rows.

I went into a lot more detail about what it might look like here: https://github.com/vlcn-io/cr-sqlite/issues/65#issuecomment-...