Skip to content

[2/4 messagequeue] Shard MySQL queues by tenant identity - #694

Draft
behinddwalls wants to merge 2 commits into
preetam/mq-tenant-rfcfrom
preetam/mq-tenant-platform
Draft

[2/4 messagequeue] Shard MySQL queues by tenant identity#694
behinddwalls wants to merge 2 commits into
preetam/mq-tenant-rfcfrom
preetam/mq-tenant-platform

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

Vitess needs a stable vindex that is not the Kafka-style partition key. Isolation has to be an explicit tenant column, with identity carried on publish and consume so two tenants sharing a partition key cannot collide.

What?

  • Prefix every queue table and store query with tenant; set queue_offsets PK to (tenant, topic, partition_key, consumer_group).
  • Use typed (tenant, partitionKey) identities in consumers, gates, and MySQL workers; stop workers when lease discovery cannot confirm ownership.
  • Require tenant on publish.Message and validate payload queue against message tenant in pipeline controllers (the publish signature change is not compilable without those call sites).
  • Add ParseRequiredTenants and wire Stovepipe ingest to the configured tenant list so NewIngestController still builds.
  • Require tenant xor all-tenants on MQ admin list commands; message inspect/delete/requeue take the full (tenant, topic, partition, id) identity.

Test Plan

go test on mysql, publish, consumer, messagequeue identity, service/messagequeue, and start controller

Issues

Stack

  1. [1/4 messagequeue] RFC: per-tenant sharding for the MySQL message queue #693
  2. @ [2/4 messagequeue] Shard MySQL queues by tenant identity #694
  3. [3/4 messagequeue] Wire MQ_TENANTS through services and tests #695
  4. [4/4 messagequeue] Add Vitess vschema and two-shard vtcombo suite #696

behinddwalls and others added 2 commits September 7, 2026 23:05
## Summary

### Why?

Vitess needs a stable vindex that is not the Kafka-style partition key. Isolation has to be an explicit tenant column, with identity carried on publish and consume so two tenants sharing a partition key cannot collide.

### What?

- Prefix every queue table and store query with tenant; set queue_offsets PK to (tenant, topic, partition_key, consumer_group).
- Use typed (tenant, partitionKey) identities in consumers, gates, and MySQL workers; stop workers when lease discovery cannot confirm ownership.
- Require tenant on publish.Message and validate payload queue against message tenant in pipeline controllers (the publish signature change is not compilable without those call sites).
- Add ParseRequiredTenants and wire Stovepipe ingest to the configured tenant list so NewIngestController still builds.
- Require tenant xor all-tenants on MQ admin list commands; message inspect/delete/requeue take the full (tenant, topic, partition, id) identity.

## Test Plan

✅ `go test` on mysql, publish, consumer, messagequeue identity, service/messagequeue, and start controller

Co-authored-by: Cursor <cursoragent@cursor.com>
## Summary

### Why?

The CREATE TABLE statements encode two different VARCHAR(255) contracts. A reader opening the SQL should see the byte vs character limits, binary collations, and why tenant stays ASCII.

### What?

- Comment ascii/ascii_bin vs utf8mb4/utf8mb4_bin on every queue table, with the full encoding note on queue_messages.

Co-authored-by: Cursor <cursoragent@cursor.com>
@behinddwalls
behinddwalls force-pushed the preetam/mq-tenant-platform branch from 6ac133e to 58adda2 Compare September 8, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant