DO NOT MERGE: feat(sharding): add label-driven predicate routing #9574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE
POC/Experiment for review / discussion purposes only.
This is a proof-of-concept implementation for label-based predicate sharding. It is intended for review and testing purposes only.
Summary
Add
@label(name)directive to predicates, allowing them to be pinned to specific alpha groups that share the same label. This creates implicit sub-clusters for data isolation.Key Changes
labelfield toMember,Tablet, andSchemaUpdateprotos@label(X)directive in schema (schema/parse.go)Tablet(),BelongsTo(),ForceTablet()/moveTabletvalidates label compatibility: blocks moves when destination group label differs from predicate labelLabel Routing Flow
Example Usage
Testing Instructions
Prerequisites
Run the Tests
Test Cluster Configuration
The tests spin up a Docker cluster with:
zero1alpha1alpha2secret@label(secret)predicatesalpha3top_secret@label(top_secret)predicatesWhat the Tests Verify
TestLabeledAlphaRegistration--label=Xcorrectly register their label with Zero. VerifiesMember.Labelis set in cluster state.TestLabeledPredicateRouting@label(X)are assigned to the group whose alpha has matching label. Verifies tablet assignments in Zero's/stateendpoint.TestLabeledPredicateDataIsolationTestLabeledPredicateCannotBeMoved/moveTabletAPI validates label compatibility. Attempting to move a labeled predicate to a group with a different (or no) label returns an error. This ensures predicates stay within their designated label boundary.TestUnlabeledPredicateNotOnLabeledGroupTestMissingLabelGroupError@label(nonexistent)returns a clear error when no alpha has that label.Test Plan
TestLabeledAlphaRegistration✓TestLabeledPredicateRouting✓TestLabeledPredicateDataIsolation✓TestLabeledPredicateCannotBeMoved✓TestUnlabeledPredicateNotOnLabeledGroup✓TestMissingLabelGroupError✓All 6 integration tests pass.