-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (sync service): multi tenancy (#1886)
_Closes #1868, closes #1844. I kept that PR up to consult its diff until all the issues have been resolved here._ This PR fixes #1591. It enables Electric to work with multiple databases (i.e. tenants). ### Architectural overview ![multi-tenant-electric](https://github.com/user-attachments/assets/9129d146-288d-43ea-8a9d-879656173443) TODO: - [x] rebase on top of main - [x] review commented out code and either remove it or make sure the place it had been moved to has been updated for multitenancy - [x] add a `database_id` query param to the health endpoint to request the health of a given tenant - [x] extract `validate_tenant_id`, `load_tenant` and `assign_tenant` which currently are duplicated in the create shape plug and delete shape plug. - [x] Implement a two-tier ETS storage for column info and relation data. In this PR we replace two named tables with anonymous ones, necessitating a roundtrip to a single gen server just to fetch the table handle. This gen server becomes a bottleneck. We should either create another static ETS table to lookup individual ETS table handles in or store all column info and relation info in two static (named) tables, ensuring they don't trump each other via proper key design. - [x] unit tests for multi tenancy - [x] unit tests for add DB plug - [x] unit tests for delete DB plug - [x] e2e tests for multi tenancy - [x] debug flaky cache tests - [x] add a diagram explaining the new architecture - [x] update the open API spec (for add DB endpoint and remove DB endpoint) - [x] persist tenant information and restore it on startup - [ ] e2e test for persistence of tenants - [x] Generate a random database id (i.e. tenant id) if you only provide a database_url env var --------- Co-authored-by: Oleksii Sholik <[email protected]> Co-authored-by: msfstef <[email protected]> Co-authored-by: Ilia Borovitinov <[email protected]>
- Loading branch information
1 parent
0d23660
commit 3775f1c
Showing
75 changed files
with
3,020 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
LOG_LEVEL=info | ||
DATABASE_URL=postgresql://postgres:password@localhost:54321/postgres?sslmode=disable | ||
DATABASE_ID=test_tenant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
listen_addresses = '*' | ||
wal_level = logical # minimal, replica, or logical | ||
port = 5433 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.