Skip to content

Sharding Architecture 🟑 BETA

Database sharding is not implemented in this tree; read the table below before planning capacity around it.

Overview

A search of botserver/src and botserver/crates finds no shard-configuration table, tenant-to-shard mapping or shard-aware router for the main database. The only shard fields found belong to the knowledge-base indexer and to sharded test-report merging, neither of which is a database sharding feature. A page that described a shard routing table would be describing code that does not exist.

Capability Status in this tree Consequence
Tenant-to-shard mapping not implemented all tenants share the configured database
Shard-aware routing not implemented no route key is read from a shard table
Per-shard migration runner not implemented migrations apply to one database
Cross-shard queries not implemented there is no second shard to query
Per-shard failover not implemented use database backups and replicas instead

Shard Configuration

Shard Config Table

No such table is declared in botschema or in the migrations. Do not add a config.csv key for it: a key with no consumer is not a setting.

Example Configuration

There is no example to copy. Record a proposal as an issue, not as documentation of a shipped feature.

Tenant-to-Shard Mapping

Mapping Table

Tenant ownership is recorded in the ordinary scoped columns (org_id, branch_id) and in object-storage prefixes. That is the isolation boundary that exists today; see multi-tenant isolation.

Routing Logic

Requests are scoped by the verified tenant, not routed to a shard. A future routing layer would have to preserve that rule.

Data Model Requirements

Every Table Includes Shard Keys

The existing schema has tenant scope columns, not shard keys. Any future change must go through a migration and update botschema; table! macros live only in that crate.

Foreign Keys Within Shard Only

With one database, foreign keys remain within that database. Do not describe a cross-shard foreign-key policy as implemented.

Snowflake ID Generation

ID generation is separate from any sharding scheme. Read the source for the current generator rather than asserting an ID layout here.

Query Patterns

Single-Tenant Queries (Most Common)

Every query carries the verified tenant predicate. See the security matrix.

Cross-Shard Queries (Admin Only)

Not applicable: there are no multiple shards. An admin query still needs the normal authorisation and tenant scope.

Scatter-Gather Pattern

Not implemented.

High Availability

Per-Shard Replication

Use the database's own replication and the documented backup runbook.

Failover Configuration

Read the deployment's database configuration; do not add a shard-level failover setting that nothing consumes.

Monitoring

Key Metrics Per Shard

There is one database, so monitor database latency and connection count in the SLO panel.

Shard Health Check

Not applicable. Monitor the database container instead.

Verify

Check Command / surface Pass condition
Schema grep -RIn "shard" botschema no shard-config table declared
Source source grep no tenant-to-shard router
Tenant scope cross-tenant probe refused
Schema ownership table! locations only in botschema

Roll back

πŸ”΄ This page makes no production change. A future implementation is tracked as an issue and documented only after code exists; any prototype change is reverted through the deploy runbook.