electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
9.49k stars 204 forks source link

fix: Transactional application of `ShapeStream` messages #336

Closed msfstef closed 2 months ago

msfstef commented 2 months ago

Should apply all messages from ShapeStream transactionally (even though with chunking you cannot guarantee that the batch of messages received form a transaction) - previously was using one transaction per message and blocking the main loop as well!

We could potentially remove the transaction altogether but I'm assuming that pg might optimize writing many messages together when committing as a transaction either way.

I've also awaited each transaction to finish as the new version of ShapeStream will be able to apply backpressure based on the callback provided to process messages, and avoid flooding PG

github-actions[bot] commented 2 months ago

Built bundles:

github-actions[bot] commented 2 months ago

🚀 Deployed on https://66f17dcf9ba64e2d71946768--pglite.netlify.app