Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
e3ce981
MultigresCluster CR Initial Design Proposal
fernando-villalba Oct 15, 2025
bcdb315
Fixing typo
fernando-villalba Oct 15, 2025
2d23ad0
Apply suggestions from code review
fernando-villalba Oct 16, 2025
0b784bc
Adding operator delegator section
fernando-villalba Oct 16, 2025
cb6c4ce
Adding more detail and questions, reordering them by order of importa…
fernando-villalba Oct 17, 2025
dce7278
Adding some ASCII diagram
fernando-villalba Oct 17, 2025
9fddea7
Adding corrections to the ASCII diagram
fernando-villalba Oct 17, 2025
1a2d23f
More corrections
fernando-villalba Oct 20, 2025
a897728
Minor corrections
fernando-villalba Oct 20, 2025
b837c4b
Adding a final CR definition based on our conversations yesterday for…
fernando-villalba Oct 21, 2025
64d5470
Last updates
fernando-villalba Oct 21, 2025
6e5d0c5
adding deployment templates as a separate CR
fernando-villalba Oct 21, 2025
068755f
Some corrections
fernando-villalba Oct 22, 2025
b7ad4e3
further corrections
fernando-villalba Oct 22, 2025
ae0b2c4
Moved multiorch under cell CR and updated the ASCII diagram
fernando-villalba Oct 22, 2025
193f27e
Further templating
fernando-villalba Oct 22, 2025
9a37c5a
Additional corrections
fernando-villalba Oct 22, 2025
7df4743
minor updates
fernando-villalba Oct 22, 2025
fe266f2
Changing the names of some of the resources
fernando-villalba Oct 24, 2025
adb36e4
Addressing some of Ryotas comments
fernando-villalba Oct 27, 2025
3a3862a
Update plans/phase-1/final-cr-definition.md
fernando-villalba Oct 27, 2025
2238b1c
Addressing Ryotas comment
fernando-villalba Oct 27, 2025
fc14ef4
Removing dash from table-group
fernando-villalba Oct 27, 2025
475ecf0
Refactor: Remove unnecessary 'templates' wrapper from cluster spec
fernando-villalba Oct 27, 2025
201ffd0
Removed comment that could be misinterpreted as it may not be the way…
fernando-villalba Oct 27, 2025
d48544f
Adding a note about allcells
fernando-villalba Oct 27, 2025
2310019
Removing ambiguous statement
fernando-villalba Oct 27, 2025
6a7620e
Removing the images as templates field
fernando-villalba Oct 27, 2025
716f51a
Fixing issue with topoServer cell spec
fernando-villalba Oct 27, 2025
844d905
Forgot to add the status for this
fernando-villalba Oct 27, 2025
1d8f61a
Starting to turn this into a proper document, NOT finished yet
fernando-villalba Oct 27, 2025
7a1432f
Update to the CR document with more details and clean up and clarify …
fernando-villalba Oct 28, 2025
6d70e60
Final draft
fernando-villalba Oct 28, 2025
55720a3
Adding index
fernando-villalba Oct 28, 2025
c0178e7
Update plans/phase-1/final-cr-definition.md
fernando-villalba Oct 28, 2025
787ec3a
Apply suggestions from code review
fernando-villalba Oct 28, 2025
d90592a
Removing redundant or confusing comments
fernando-villalba Oct 28, 2025
259257e
Adding note about template status field
fernando-villalba Oct 28, 2025
393d7dd
Adding clarification for image fields
fernando-villalba Oct 28, 2025
9868578
Adding an appendix with additional information
fernando-villalba Oct 28, 2025
a3f870e
Apply suggestions from code review
fernando-villalba Oct 29, 2025
7c81ac4
Apply suggestions from code review
fernando-villalba Oct 29, 2025
cb0ee95
Adding Helm as an alternative considered
fernando-villalba Oct 29, 2025
7dbca27
Deleting references to multigrescluster-cr-definition.md
fernando-villalba Oct 29, 2025
59f4dde
Apply suggestions from code review
fernando-villalba Oct 29, 2025
c1127d1
Apply suggestions from code review
fernando-villalba Oct 29, 2025
60ff2ff
Apply suggestions from code review
fernando-villalba Oct 29, 2025
ac07cbd
Removing status field for deployment template and adding a comment ex…
fernando-villalba Oct 29, 2025
b5bb7a0
Update plans/phase-1/final-cr-definition.md
fernando-villalba Oct 29, 2025
3ead065
Fixing some indentation
fernando-villalba Oct 29, 2025
43c6b55
Apply suggestions from code review
fernando-villalba Oct 29, 2025
0d87c8f
Apply suggestions from code review
fernando-villalba Oct 29, 2025
808258b
Add one more discussion point to the document
fernando-villalba Oct 29, 2025
7ebdc22
Update plans/phase-1/final-cr-definition.md
fernando-villalba Oct 29, 2025
e326744
API design ready for Supabase review
fernando-villalba Oct 29, 2025
4490a23
First draft of alternative design, NOT complete yet
fernando-villalba Nov 5, 2025
25259e0
Removing useless references
fernando-villalba Nov 5, 2025
30066ae
Correcting tablegroup
fernando-villalba Nov 5, 2025
82db33e
Redesigning alternative proposal
fernando-villalba Nov 6, 2025
38845d9
Adding a few changes
fernando-villalba Nov 6, 2025
13768f4
New version with ShardTemplates and CellTemplates
fernando-villalba Nov 7, 2025
56e3094
Changing spec to implement atomic overrides
fernando-villalba Nov 10, 2025
0594146
Introduced a consistent 4-level override chain (inline/explicit-templ…
fernando-villalba Nov 11, 2025
84c1340
New design implementing DDL and declarative creation of DBs
fernando-villalba Nov 14, 2025
ecc6482
Some corrections and clarifications
fernando-villalba Nov 14, 2025
5b21a22
Removing pointless file references
fernando-villalba Nov 14, 2025
5b0bcaa
finalizing design and placing old designs into different location
fernando-villalba Nov 18, 2025
a58fb91
Making some corrections to address Ryotas feedback
fernando-villalba Nov 20, 2025
ad01afa
Changing the images for the child CRs to be like it was in the origin…
fernando-villalba Nov 20, 2025
041e9fd
Clarifying the read-only bit
fernando-villalba Nov 20, 2025
f1afd1f
renaming managedSpec to managed
fernando-villalba Nov 21, 2025
f1e9d56
Removing all precedence references
fernando-villalba Nov 21, 2025
2a7902a
Adding the default flag for tablegroups and databases
fernando-villalba Nov 21, 2025
fd97947
Nesting the globaltoposerver for tablegroup and shards
fernando-villalba Nov 24, 2025
4048b01
Adding a configuration to opt out of multiorch per pooler. The replic…
fernando-villalba Nov 24, 2025
9bdf48b
Changing the managed field to etcd in case in the future we would wan…
fernando-villalba Nov 24, 2025
82c2f06
refactor(api): use explicit 'cells' list for pools and multiorch
fernando-villalba Nov 25, 2025
1c38c86
Changing pools replicas to replicasPerCell to make it clear it is per…
fernando-villalba Nov 26, 2025
8ced166
Update plans/phase-1/api-design/multigres-operator-api-v1alpha1-desig…
fernando-villalba Nov 27, 2025
9647daa
Update plans/phase-1/api-design/multigres-operator-api-v1alpha1-desig…
fernando-villalba Nov 27, 2025
62d1572
Update plans/phase-1/api-design/multigres-operator-api-v1alpha1-desig…
fernando-villalba Nov 27, 2025
c8a218c
Apply suggestions from code review
fernando-villalba Nov 27, 2025
e81d28c
Apply suggestions from code review
fernando-villalba Nov 27, 2025
d7ce942
Minor clarification on map usage on pools
fernando-villalba Nov 27, 2025
0e66fe8
Moving default section
fernando-villalba Nov 27, 2025
c1d3a1a
Update plans/phase-1/api-design/multigres-operator-api-v1alpha1-desig…
fernando-villalba Nov 28, 2025
0d53ab7
Apply suggestions from code review
fernando-villalba Nov 28, 2025
f61d405
Apply suggestions from code review
fernando-villalba Dec 1, 2025
fcd4273
Removing redundant webhook validation
fernando-villalba Dec 1, 2025
6982bad
Changing finalizer name
fernando-villalba Dec 1, 2025
2614c55
Changing template deletion mechanism
fernando-villalba Dec 1, 2025
da83b30
Clarification
fernando-villalba Dec 1, 2025
a1c9a56
Apply suggestions from code review
fernando-villalba Dec 3, 2025
20a1bf3
Correcting multigateway naming
fernando-villalba Dec 4, 2025
a5e9552
Adding a fail safe condition scenario
fernando-villalba Dec 4, 2025
0865b23
Adding affinity options to pools
fernando-villalba Dec 4, 2025
78ebcc1
Changing primary name to main-app
fernando-villalba Dec 4, 2025
5553c67
Update plans/phase-1/api-design/multigres-operator-api-v1alpha1-desig…
fernando-villalba Dec 5, 2025
41d7ee2
Removing redundant replica
fernando-villalba Dec 5, 2025
668e5a0
Correcting status shard spec
fernando-villalba Dec 5, 2025
f0735eb
Update plans/phase-1/api-design/multigres-operator-api-v1alpha1-desig…
fernando-villalba Dec 5, 2025
cb02322
Apply suggestions from code review
fernando-villalba Dec 5, 2025
cd7580c
Adding clustername prefix
fernando-villalba Dec 5, 2025
c971fa0
Adding the missing image on etcd
fernando-villalba Dec 5, 2025
d31dad5
Adding webhook naming validation
fernando-villalba Dec 5, 2025
9ab88f0
Adding missing default flag and addressing a few PR comments
fernando-villalba Dec 8, 2025
fa6a6cf
Adding a few missing pieces and correcting others
fernando-villalba Dec 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed plans/.gitkeep
Empty file.
102 changes: 102 additions & 0 deletions plans/phase-1/api-design/additional-context/data-relationships.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: MultigresCluster Canonical Data Sources and Relationships
state: ready
---

## Summary
> This document was provided by Sugu to explain how database and shard schema is stored in a postgres database and the problem of having two sources of truth for this databases definition: Kubernetes Cluster and Multigres.


Multigres is going to have metadata in multiple places and in some cases, they have to be duplicated. If so, we have define which one is the canonical source of truth. We will also define the relationships between the different data sources.

## List of Data Sources

In a Kubernetes cluster the following data sources are used:

- Kubernetes CRD templates: This contains all the CRDs for the Multigres Operator. This is static. Example: `MultigreCluster` type.
- Kubernetes CRs: These are Kubernetes meta-objects that are instances of the CRDs. Kubernetes lets the operator manage their lifecycle. Example: `MultigreCluster` objects.
- Kubernetes objects: These are real objects like pods and services.

For simplicity, we'll unify all of the above data sources as one storage type: Kubernetes Store.

In Multigres, we have the following data sources:

- Global Toposerver: This stores the name of each MultigresCluster. Under each, it stores the per-cell metadata:
- Cell Name
- Local Toposerver Address

- Local Toposerver: Components running within a cell register themselves in this server. Components can discover each other using this server.

- Default TableGroup metadata: Simply put, this is a hidden area within the default database of the first Postgres server created for the MultigresCluster. In Multigres parlance, this first database is the only shard of the "default" tablegroup, which is inside the Multigres default database. Just like every Postgres server creates a default database, Multigres creates a logical default database that contains this unsharded tablegroup with a single shard. Essentially, `Multigres->Default Database->Default TableGroup->Only Shard` is the same as `Postgres->Default Database`. This metadata area contains:
- A list of databases.
- For each database, a list of tablegroups, of which the default is always present.
- For each tablegroup, a list of shards. For the default tablegroup, it's always a single shard, which is the current database.

| Postgres | Physical Multigres |
|----------|---------------------|
| Server | Multigres Cluster |
| Database | Multigres Database->TableGroups->Shards (physical PG servers) |
| Default Database | Multigres Default Database->Default TableGroup->Only Shard |
| create table t | t is created in: Multigres Default Database->Default TableGroup->Only Shard |
| (new syntax) | Create tablegroup tg1 for db1 |
| create table t1 in tg1 (new syntax) | Table t1 in all shards of tg1 |

In other words, a multigres cluster would have the following metadata:
- default database
- default tablegroup
- only shard
- db1
- default tablegroup
- only shard
- tg1
- shard "0-8"
- shard "8-inf"

In this structure, we have a chicken-and-egg problem because this information also exists in the Kubernetes Store under the `MultigresCluster` custom resource.

## Life of a cluster

### Cluster initialization

In the beginning, we have the Multigres Operator (MGO) running. In Kubernetes, CRD templates are already registered.

MGO receives a command to create a new MultigresCluster. Let us assume:

- Cluster name cluster1
- Single cell c1
- Single components in c1: MultiPooler, MultiGateway, and MultiOrch

MGO Actions:

- MGO creates (or reuses) a Global Toposerver. Root path: `/multigres`.
- Creates a new entry: `/multigres/cluster1/global`
- Under the above entry, it creates the following subentries:
- `/multigres/cluster1/global/cell1`
- `/multigres/cluster1/global/cell1/local-toposerver`: This contains the address of the local toposerver.
- MGO creates (or reuses) a Local Toposerver. Root path: `/multigres/cluster1/cell1`. No subentries at this point.
- MGO launches the pods and services for MultiPooler, MultiGateway, and MultiOrch.

Multigres Actions:

- MultiPooler comes up and registers itself with the local toposerver under `/multigres/cluster1/cell1/`.
- MultiPooler initializes an empty postgres database. In this database, it creates a hidden area for the multigres metadata. In it, it adds a default tablegroup, and a single shard, which represents the current database.
- MultiOrch discovers the MultiPooler, notices that it's a single instance situation, appoints the MultiPooler as Primary, and requests it to accept read-write traffic.
- MultiGateway discovers MultiPooler. It's for the default tablegroup. It fetches the tablegroup metadata from MultiPooler, and discovers only the default tablegroup. It sets itself up to serve traffic for this tablegroup.

Users:

- Connect to MultiGateway (with no database name). This is implicitly resolved to the default tablegroup. They can create tables and use this database just like the default database of Postgres.

#### What is the problem

The default tablegroup info is present in two places:
- It's (implicitly) present in the Multigres Cluster definition.
- It's present in the postgres database under the hidden area created by MultiPooler.

One may argue that the Multigres Cluster definition is the canonical source of truth. However, this will put the burden of maintaining the database metadata on the MultiPooler, which is not ideal. Also, this increases the surface area between MGO and Multigres.

The alternative is to have the database be the source of truth, and MGO drive off of that. We'll analyze options arising out of this approach below.

### Create Database

User issues `CREATE DATABASE db1;`
Loading