Recently released Clojure implementation of the same pattern: https://github.com/eerohele/muutos
I saw the post on the clojure subreddit! I’m stoked to try it out. Ever since I saw Martin Kleppman’s “Turning the database inside out” talk I’ve wanted an easy way to hook into a transaction log. Apache samza/kafka is very cool but I’m not going to set it up for personal projects. It’d be VERY cool to make materialized views straight from the log!!
Listen to Database Changes Through the Postgres WAL
41–50 of 54 posts
Re: Listen to Database Changes Through the Postgres WAL
#42Earlier quoted context omitted.
The problem is that unclean connector shutdowns are a thing that can happen in real life.
They can happen, yes, although this should be a rather rare event (the most common reason would be misconfiguration, such as a K8s pod with too low memory limits). That said, work towards exactly-once has been done [1], utilizing the support for EOS in Kafka Connect (KIP-618). In particular for Postgres, consumers can detect and reject duplicates really easy though, by tracking a watermark for the {Commit LSN / Event…
For our use case, it didn't matter if it was rare or not: the fact that it could happen at all meant we needed to be robust to it, which basically meant storing the entire database in memory.
> We added support for exposing this via the `source.sequence` field a while back upon request by the Materialize team btw.
Yes, I helped work on this! I'm not sure whether Materialize is still using it (it's been years since I've thought about MZ/Debezium integration) but it was helpful, thanks.
Re: Listen to Database Changes Through the Postgres WAL
#43Please stop doing this via database. Scaling issues can develop and we in Ops catch flak for your bad design choices. Use Kafka/RabbitMQ/Redis PLEASE.
Re: Listen to Database Changes Through the Postgres WAL
#44The Ops person in me is crying. Please stop doing this via database. Scaling issues can develop and we in Ops catch flak for your bad design choices. Use Kafka/RabbitMQ/Redis PLEASE.
Re: Listen to Database Changes Through the Postgres WAL
#45The Ops person in me is crying. Please stop doing this via database. Scaling issues can develop and we in Ops catch flak for your bad design choices. Use Kafka/RabbitMQ/Redis PLEASE.
Re: Listen to Database Changes Through the Postgres WAL
#46The Ops person in me is crying. Please stop doing this via database. Scaling issues can develop and we in Ops catch flak for your bad design choices. Use Kafka/RabbitMQ/Redis PLEASE.
Those can listen to database changes and aren't separate services to set up, keep online and pay for? Neat (and news to me)!
Sure, if you are tiny, will forever remain tiny, then whatever, ignore this Ops person.
Re: Listen to Database Changes Through the Postgres WAL
#47Earlier quoted context omitted.
Those can listen to database changes and aren't separate services to set up, keep online and pay for? Neat (and news to me)!
Except if you disconnect for any reason, you will miss changes. If you want to break out services into different servers, clients will still be crossing the streams to listen. Database schema changes must be coordinated properly. Basically, you are taking one database to rule them all model which comes with massive drawbacks and inserting additional capabilities into it. Sure, if you are tiny, will forever remain tin…
Re: Listen to Database Changes Through the Postgres WAL
#48It is probably best to use that unless there is a strong reason against.
Re: Listen to Database Changes Through the Postgres WAL
#49Recently released Clojure implementation of the same pattern: https://github.com/eerohele/muutos
I saw the post on the clojure subreddit! I’m stoked to try it out. Ever since I saw Martin Kleppman’s “Turning the database inside out” talk I’ve wanted an easy way to hook into a transaction log. Apache samza/kafka is very cool but I’m not going to set it up for personal projects. It’d be VERY cool to make materialized views straight from the log!!
This is what Materialize does. You point it at some PG (or MySQL, or... probably lots more by now) sources, and then you can define arbitrary views on top of those sources using SQL (with the full power of relational logic: fully precise joins, etc.) The views are maintained incrementally, so they update almost instantly when the underlying data updates; you don't have to manually refresh them.
Disclaimer: I worked on Materialize for five years, and it is a commercial, proprietary project. But it is source-available (https://github.com/materializeinc/materialize) under a BSL-style license, and it has fairly generous terms for free usage.