electric-sql / electric

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

chore (sync service): refactor tenant manager to store tenant info in ETS table #1953

Closed kevin-dp closed 2 weeks ago

kevin-dp commented 2 weeks ago

This PR applies the refactoring proposed by @icehaunter which consists of storing the tenant information in a protected ETS table. Any process can read the tenant information from the ETS table.

Concurrent reads

On every shape request the tenant information is loaded from the ETS table. Concurrent shape requests can read this information from the ETS table concurrently.

Serialised writes

Writes to the ETS table are less frequent (only when adding or removing tenants) and are still serialised through the tenant manager's genserver and thus are not prone to race conditions.