Repository navigation
Open
Description
Is there an existing issue for the same tech request?
- I have checked the existing issues.
Does this tech request not affect user experience?
- This tech request doesn't affect user experience.
What would you like to be added?
Tenant-Aware Catalog Logtail Subscription for CN Nodes
Currently, when a CN starts up, it subscribes to the full logtail of system catalog tables (mo_database, mo_tables, mo_columns) via PushClient.subSysTables(). The TN sends all tenants catalog data to every CN, and the CatalogCache stores entries for all accounts in memory, only filtering by AccountId at query time.
Current flow:
- CN calls subSysTables() -> subscribes to MO_DATABASE_ID, MO_TABLES_ID, MO_COLUMNS_ID (no tenant filter)
- TN collects and pushes logtail for these tables containing all tenants data
- CN applyToCatalogCache() inserts all rows into CatalogCache (btree of TableItem/DatabaseItem)
- Query-time filtering: CatalogCache.Tables(accountId, ...) / CatalogCache.Databases(accountId, ...) filters by account
Proposed optimization:
Add tenant-level filtering to the catalog logtail subscription path so each CN only receives and caches catalog entries for the tenants it actually serves.
Key changes needed:
- Subscription-level filtering: Extend logtail subscription protocol to carry tenant/account info, so TN can filter catalog entries before sending
- TN-side filtering: When collecting logtail for mo_database/mo_tables/mo_columns, filter rows by account_id based on subscribing CN tenant scope
- CN-side awareness: CN should know which tenants it serves and communicate this during subscription
- Dynamic tenant changes: Handle cases where tenant-to-CN mapping changes
Why is this needed?
In multi-tenant deployments with many tenants (hundreds or thousands):
- Memory waste: Every CN caches catalog metadata for ALL tenants in CatalogCache, even if it only serves a subset. Each TableItem is a large struct with TableDef, Constraint, CreateSql, etc.
- Network bandwidth waste: TN pushes all tenants catalog logtail to every CN, multiplying network traffic by CN count
- Replay overhead: CN replays catalog entries for tenants it never serves, wasting CPU during startup and incremental updates
- GC pressure: Larger CatalogCache means more work during GC cycles
- Scalability bottleneck: Per-CN overhead grows linearly with tenant count regardless of actual tenant assignment
Additional information
Considerations:
- System account (account_id=0) catalog entries are needed by all CNs
- Should consider lazy loading as alternative or complementary approach
Metadata
Metadata
Assignees
Labels
kind/tech-requestNew feature or request
Activity