Skip to content

feat(vitess): implement vitess_tasks for VSchema progress tracking#99

Draft
aparajon wants to merge 1 commit into
mainfrom
armand/vschema-progress-visibility
Draft

feat(vitess): implement vitess_tasks for VSchema progress tracking#99
aparajon wants to merge 1 commit into
mainfrom
armand/vschema-progress-visibility

Conversation

@aparajon
Copy link
Copy Markdown
Collaborator

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.

  • Track which keyspaces have VSchema changes in apply metadata
  • Synthesize VSchema table entries in the engine Progress response with state derived from the deploy request deployment state
  • Pass synthetic VSchema entries through the LocalClient proto conversion so they reach the CLI
  • Add shared VSchemaTablePrefix constant used by both the engine and CLI for consistent detection
  • Fix double-space typo in "Validating deploy request" TUI message

Copilot AI review requested due to automatic review settings May 13, 2026 17:01
@aparajon aparajon changed the title feat(vitess): add VSchema progress visibility and fix TUI formatting fix(vitess): add VSchema progress visibility and fix TUI formatting May 13, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.VSchemaTablePrefix constant 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.

Comment thread pkg/tern/local_client.go Outdated
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 thread pkg/engine/engine.go
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)
})
@aparajon aparajon force-pushed the armand/vschema-progress-visibility branch from 38f03ff to fbe2278 Compare May 15, 2026 17:11
@aparajon aparajon changed the title fix(vitess): add VSchema progress visibility and fix TUI formatting feat(vitess): implement vitess_tasks for VSchema progress tracking May 15, 2026
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>
@aparajon aparajon force-pushed the armand/vschema-progress-visibility branch from fbe2278 to 2bb641e Compare May 20, 2026 00:47
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.

2 participants