litestream icon indicating copy to clipboard operation
litestream copied to clipboard

Change Data Capture

Open benbjohnson opened this issue 3 years ago • 8 comments

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.

benbjohnson avatar Mar 19 '21 20:03 benbjohnson

Tidb has cdc so adding in case it helps

https://github.com/pingcap/ticdc

gedw99 avatar Apr 15 '21 15:04 gedw99

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

benbjohnson avatar Apr 16 '21 21:04 benbjohnson

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.

simonw avatar May 01 '21 00:05 simonw

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

  • https://github.com/bvinc/go-sqlite-lite/blob/master/sqlite3/session.go
  • https://github.com/crawshaw/sqlite/blob/master/session.go
  • Issue request https://github.com/mattn/go-sqlite3/issues/825

freshteapot avatar Jul 26 '21 20:07 freshteapot

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

gedw99 avatar Aug 03 '21 12:08 gedw99

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

freshteapot avatar Aug 08 '21 09:08 freshteapot

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

gedw99 avatar Oct 28 '21 09:10 gedw99

interested ;)

fujohnwang avatar Nov 09 '23 13:11 fujohnwang