electric-sql / electric

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

feat: use tenants from external source #1967

Closed icehaunter closed 1 week ago

icehaunter commented 1 week ago

Allows configuring the external source to pull the tenant information from. External source is expected to be an Electric instance.

Notable changes:

  1. If no external source is provided, the system always functions in a single-tenant mode
  2. Since tenant id is not preserved across restarts, in single-tenant mode we hard-code the id to UUID0
  3. If external source is not available, the calls to add a db will fail
  4. If external source has changed while this instance was down, it will try to delete all tenant information it can, pending a feature to clean up shapes after deleted tenants

Closes #1961

netlify[bot] commented 1 week ago

Deploy Preview for electric-next ready!

Name Link
Latest commit 04802ce44b47d5580bcab3baefb603e25bcebb64
Latest deploy log https://app.netlify.com/sites/electric-next/deploys/67334e7e942328000742f8f6
Deploy Preview https://deploy-preview-1967--electric-next.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

balegas commented 1 week ago

@icehaunter can you elaborate a bit more on

If external source has changed while this instance was down, it will try to delete all tenant information it can, pending a feature to clean up shapes after deleted tenants

I read this as: if electric is briefly unavailable and misses an update to some of the tenants it hosts, it will drop all tenants info. Why is that and why can't we do better?

kevin-dp commented 1 week ago

@icehaunter can you elaborate a bit more on

If external source has changed while this instance was down, it will try to delete all tenant information it can, pending a feature to clean up shapes after deleted tenants

I read this as: if electric is briefly unavailable and misses an update to some of the tenants it hosts, it will drop all tenants info. Why is that and why can't we do better?

It won't. What @icehaunter meant is that tenants may have been added and/or deleted while Electric was down. On restart, Electric will get these updates from the control plane. For each tenant that was deleted, Electric will remove the tenant's shape data from disk (remains to be implemented). For each tenant that was added, Electric will create that tenant.