benbjohnson / litestream

Streaming replication for SQLite.
https://litestream.io
Apache License 2.0
11.1k stars 256 forks source link

Change Data Capture #129

Open benbjohnson opened 3 years ago

benbjohnson commented 3 years ago

While Litestream performs physical replication of WAL frames, it would be useful to derive logical changesets from those physical pages. This could be done by using the Ptrmap pages to traverse up the b-tree to the root and from the root page number we can associate the changed page with a table & schema.

One tricky part would be determining how this information is relayed to the application. It could potentially be streamed via a unix socket and the application could have a client that connects to it.

The resulting stream could be a stream of JSON objects or perhaps the session extension format could be used.

gedw99 commented 3 years ago

Tidb has cdc so adding in case it helps

https://github.com/pingcap/ticdc

benbjohnson commented 3 years ago

Thanks, @gedw99. I didn't realize PingCAP had a CDC.

simonw commented 3 years ago

This would be incredibly useful. I've built systems in the past that listen to the MySQL replication stream and turn that into events - having that capability for SQLite would be fantastic.

freshteapot commented 3 years ago

Seeing you mentioned the sessions extension, I got curious what is the state of its use in go on github.

gedw99 commented 3 years ago

@freshteapot I asked if this is possible at https://gitlab.com/cznic/sqlite/-/issues/60

freshteapot commented 3 years ago

@gedw99 thank you for the tip! I wiill keep an eye on this project! sqlite without cgo would be very cool!

gedw99 commented 3 years ago

@benbjohnson this one is a good primer: https://medium.com/event-driven-utopia/a-gentle-introduction-to-event-driven-change-data-capture-683297625f9b

fujohnwang commented 1 year ago

interested ;)