electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.46k stars 156 forks source link

Append transaction times out with a moderate number of shapes #1725

Closed magnetised closed 2 months ago

magnetised commented 2 months ago

This is a quick fix while we work out a better strategy long term.

Currently each tx is written to each active shape in lock-step: new txns are only requested from the replication stream once all shapes have written the last one to disk.

We currently have a problem with timeouts because the write function is done via a GenServer.call/3 with a default timeout of 5s. So if there are a 1000 shapes, each taking ~5ms to write, then this call times out.

This is trivial to fix, instead of having an overall timeout for writing to all shapes, we move the timeout handling to the storage, so each individual shape will crash if its write takes too long, and the overall write call just sets a timeout of :infinity and waits.