feat(vitess): implement vitess_tasks for VSchema progress tracking#99
Draft
aparajon wants to merge 1 commit into
Draft
feat(vitess): implement vitess_tasks for VSchema progress tracking#99aparajon wants to merge 1 commit into
aparajon wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves deploy-progress visibility for PlanetScale/Vitess applies by surfacing VSchema-only work (which doesn’t show up in SHOW VITESS_MIGRATIONS) as synthetic “table” progress entries, and fixes a minor TUI formatting typo.
Changes:
- Track keyspaces with VSchema changes in PlanetScale engine apply metadata and synthesize VSchema progress rows during
Engine.Progress. - Pass synthetic VSchema progress rows through the LocalClient’s proto response so they reach CLI/TUI consumers.
- Standardize VSchema task detection via a shared
engine.VSchemaTablePrefixconstant and fix a double-space typo in the TUI message.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tern/local_client.go | Appends synthetic VSchema progress rows from the engine into the proto ProgressResponse. |
| pkg/engine/planetscale/planetscale.go | Persists VSchema keyspaces in metadata and synthesizes VSchema “table” progress rows from deploy request state. |
| pkg/engine/planetscale/planetscale_test.go | Adds a metadata round-trip test for the new VSchemaKeyspaces field. |
| pkg/engine/engine.go | Introduces shared VSchemaTablePrefix constant for consumers to detect VSchema tasks. |
| pkg/cmd/commands/watch_tui_view.go | Fixes a double-space typo in the “Validating deploy request” line. |
| pkg/cmd/commands/apply.go | Updates VSchema task detection to use the shared prefix constant. |
Comments suppressed due to low confidence (1)
pkg/engine/planetscale/planetscale.go:1804
- The new VSchema progress synthesis branch (deploy state → vschema table State mapping and table entry creation) is not covered by tests. Consider adding unit tests that assert (1) a VSchemaKeyspaces metadata value results in synthetic table rows in Progress, and (2) key deploy states map to the expected task states (pending/running/completed/failed/stopped).
// Synthesize VSchema table entries. VSchema changes don't appear in
// SHOW VITESS_MIGRATIONS — they're tracked by PlanetScale's deploy state
// machine. Derive VSchema task state from the DR deployment state.
if len(meta.VSchemaKeyspaces) > 0 {
vsState := "pending"
switch dr.DeploymentState {
case deployState.InProgressVSchema:
vsState = "running"
case deployState.InProgress, deployState.Queued, deployState.Submitting:
vsState = "pending"
case deployState.Complete, deployState.CompletePendingRevert,
deployState.InProgressCutover, deployState.PendingCutover:
vsState = "complete"
case deployState.Error, deployState.CompleteError, deployState.Failed:
vsState = "failed"
case deployState.CompleteCancel, deployState.Cancelled, deployState.InProgressCancel:
vsState = "stopped"
}
for _, ks := range meta.VSchemaKeyspaces {
result.Tables = append(result.Tables, engine.TableProgress{
Table: engine.VSchemaTablePrefix + ks,
Namespace: ks,
State: vsState,
})
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| tables = append(tables, &ternv1.TableProgress{ | ||
| TableName: et.Table, | ||
| Namespace: et.Namespace, | ||
| Status: strings.ToUpper(et.State), |
| result.Tables = append(result.Tables, engine.TableProgress{ | ||
| Table: engine.VSchemaTablePrefix + ks, | ||
| Namespace: ks, | ||
| State: vsState, |
Comment on lines
336
to
+341
| // MessageApplyingVSchema is the engine progress message emitted during the | ||
| // VSchema application phase of a deploy. Used to detect VSchema task transitions. | ||
| // VSchemaTablePrefix is used to name synthetic VSchema table entries in progress. | ||
| // Consumers (CLI, TUI) use this prefix to detect VSchema tasks vs DDL tasks. | ||
| const VSchemaTablePrefix = "VSchema: " | ||
|
|
Comment on lines
+626
to
+653
| func TestVSchemaProgressSynthesis(t *testing.T) { | ||
| // Verify VSchema keyspaces are encoded/decoded in metadata | ||
| t.Run("metadata round-trip", func(t *testing.T) { | ||
| meta := &psMetadata{ | ||
| BranchName: "test-branch", | ||
| DeployRequestID: 42, | ||
| VSchemaKeyspaces: []string{"ks_sharded", "ks_unsharded"}, | ||
| } | ||
| encoded, err := encodePSMetadata(meta) | ||
| require.NoError(t, err) | ||
|
|
||
| decoded, err := decodePSMetadata(encoded) | ||
| require.NoError(t, err) | ||
| assert.Equal(t, []string{"ks_sharded", "ks_unsharded"}, decoded.VSchemaKeyspaces) | ||
| }) | ||
|
|
||
| t.Run("empty vschema keyspaces", func(t *testing.T) { | ||
| meta := &psMetadata{ | ||
| BranchName: "test-branch", | ||
| DeployRequestID: 42, | ||
| } | ||
| encoded, err := encodePSMetadata(meta) | ||
| require.NoError(t, err) | ||
|
|
||
| decoded, err := decodePSMetadata(encoded) | ||
| require.NoError(t, err) | ||
| assert.Empty(t, decoded.VSchemaKeyspaces) | ||
| }) |
38f03ff to
fbe2278
Compare
VSchema changes are now tracked in the dedicated vitess_tasks table instead of being shoehorned into regular DDL tasks. This gives VSchema operations their own lifecycle and state management, separate from DDL tasks. - Add VitessTaskStore interface and MySQL implementation - Create vitess_tasks entries during Apply for VSchema changes - Read vitess_tasks in Progress and enrich with live engine state - Persist state updates back to vitess_tasks during progress polls - Support VSchema-only deploys (no DDL tasks) in the Progress path - Remove dead vschema_update code from regular task path Also fixes a pre-existing bug where LocalScale skipped the revert window for non-instant deploys. The processor now checks whether instant DDL was requested (instant_ddl column) rather than just eligible. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
fbe2278 to
2bb641e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
VSchema changes were invisible during deploy progress — the TUI only showed DDL table entries from SHOW VITESS_MIGRATIONS. VSchema updates are metadata-only operations tracked by PlanetScale's deploy state machine, not Vitess OnlineDDL.
VSchemaTablePrefixconstant used by both the engine and CLI for consistent detection