Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/25.0/25.0.0/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- **[Minor Changes](#minor-changes)**
- **[VReplication](#minor-changes-vreplication)**
- [Default data protection for `_reverse` workflow cancel/complete](#vreplication-reverse-workflow-data-protection)
- [`vdiff show --no-samples` strips the per-table row-sample report](#vreplication-vdiff-no-samples)
- [Preserve Materialize target data on cancel by default](#vreplication-materialize-cancel-data-protection)
- **[VTGate](#minor-changes-vtgate)**
- [Ingress bytes in query LogStats](#vtgate-logstats-ingress-bytes)
Expand Down Expand Up @@ -174,6 +175,14 @@ The `--keep-data` flag help text has been updated to note this default explicitl

See [#19906](https://github.com/vitessio/vitess/pull/19906) for details.

#### <a id="vreplication-vdiff-no-samples"/>`vdiff show --no-samples` strips the per-table row-sample report</a>

`vtctldclient vdiff ... show` now accepts a `--no-samples` flag. When set, the per-table diff report has its row-sample arrays (`MismatchedRowsSample`, `ExtraRowsSourceSample`, `ExtraRowsTargetSample`) stripped on the tablet, while the scalar counters and all other summary fields are preserved. This avoids exceeding gRPC message limits when `vdiff show` aggregates large blob/JSON row samples across every target shard. It is exposed as `no_samples` on the `VDiffShowRequest` (vtctld) and `VDiffReportOptions` (tablet) protobuf messages, and is opt-in and backward compatible.

`vdiff create --wait` also uses `no_samples` for its internal progress polls. Text output is unchanged; with `--format json`, the per-interval progress output no longer includes the row samples (they remain available via `vdiff show --verbose` once the diff completes).

See [#20870](https://github.com/vitessio/vitess/pull/20870) for details.
Comment thread
pedroalb marked this conversation as resolved.

#### <a id="vreplication-materialize-cancel-data-protection"/>Preserve Materialize target data on cancel by default</a>

`vtctldclient Materialize cancel` now preserves the materialized target tables and their data. To remove the target tables when canceling the workflow, explicitly pass `--keep-data=false`.
Expand Down
8 changes: 6 additions & 2 deletions go/cmd/vtctldclient/command/vreplication/vdiff/vdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ var (
}{}

showOptions = struct {
Arg string
Verbose bool
Arg string
Verbose bool
NoSamples bool
}{}

stopOptions = struct {
Expand Down Expand Up @@ -322,6 +323,7 @@ func commandCreate(cmd *cobra.Command, args []string) error {
Workflow: common.BaseOptions.Workflow,
TargetKeyspace: common.BaseOptions.TargetKeyspace,
Arg: uuidStr,
NoSamples: true,
Comment thread
pedroalb marked this conversation as resolved.
})
if err != nil {
return err
Expand Down Expand Up @@ -645,6 +647,7 @@ func commandShow(cmd *cobra.Command, args []string) error {
Workflow: common.BaseOptions.Workflow,
TargetKeyspace: common.BaseOptions.TargetKeyspace,
Arg: showOptions.Arg,
NoSamples: showOptions.NoSamples,
})
if err != nil {
return err
Expand Down Expand Up @@ -709,6 +712,7 @@ func registerCommands(root *cobra.Command) {
base.AddCommand(resume)

show.Flags().BoolVar(&showOptions.Verbose, "verbose", false, "Show verbose output in summaries")
show.Flags().BoolVar(&showOptions.NoSamples, "no-samples", false, "Strip the per-table diff report's row-sample arrays (keeping the scalar counters). Useful for large diffs where the samples can exceed gRPC message limits.")
Comment thread
pedroalb marked this conversation as resolved.
Comment thread
pedroalb marked this conversation as resolved.
Comment thread
pedroalb marked this conversation as resolved.
base.AddCommand(show)

stop.Flags().StringSliceVar(&stopOptions.TargetShards, "target-shards", nil, "The target shards to stop the vdiff on; default is all shards.")
Expand Down
14 changes: 14 additions & 0 deletions go/cmd/vtctldclient/command/vreplication/vdiff/vdiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/google/uuid"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/sqltypes"
Expand Down Expand Up @@ -813,3 +814,16 @@ func TestGetStructNames(t *testing.T) {
want := []string{"A", "B"}
require.Equal(t, want, got)
}

func TestShowNoSamplesFlag(t *testing.T) {
root := &cobra.Command{Use: "test"}
registerCommands(root)

showCmd, _, err := root.Find([]string{"VDiff", "show"})
require.NoError(t, err)

flag := showCmd.Flags().Lookup("no-samples")
require.NotNil(t, flag, "vdiff show must expose the --no-samples flag")
require.Equal(t, "false", flag.DefValue, "--no-samples must default to false")
require.Contains(t, flag.Usage, "gRPC message limits")
}
21 changes: 17 additions & 4 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions go/vt/proto/tabletmanagerdata/tabletmanagerdata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions go/vt/proto/vtctldata/vtctldata.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions go/vt/proto/vtctldata/vtctldata_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go/vt/vtctl/workflow/vdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ func (s *Server) VDiffShow(ctx context.Context, req *vtctldatapb.VDiffShowReques
Workflow: req.Workflow,
Action: string(vdiff.ShowAction),
ActionArg: req.Arg,
Options: &tabletmanagerdatapb.VDiffOptions{
ReportOptions: &tabletmanagerdatapb.VDiffReportOptions{
NoSamples: req.GetNoSamples(),
},
},
}

ts, err := s.buildTrafficSwitcher(ctx, req.TargetKeyspace, req.Workflow)
Expand Down
76 changes: 76 additions & 0 deletions go/vt/vtctl/workflow/vdiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,79 @@ func TestVDiffDelete(t *testing.T) {
})
}
}

func TestVDiffShow(t *testing.T) {
ctx := t.Context()
sourceKeyspace := &testKeyspace{
KeyspaceName: "sourceks",
ShardNames: []string{"0"},
}
targetKeyspace := &testKeyspace{
KeyspaceName: "targetks",
ShardNames: []string{"-80", "80-"},
}
workflow := "testwf"
uuid := uuid.New().String()
env := newTestEnv(t, ctx, defaultCellName, sourceKeyspace, targetKeyspace)
t.Cleanup(env.close)

env.tmc.strict = true
action := string(vdiff.ShowAction)

expectedShowRequest := func(noSamples bool) *tabletmanagerdatapb.VDiffRequest {
return &tabletmanagerdatapb.VDiffRequest{
Keyspace: targetKeyspace.KeyspaceName,
Workflow: workflow,
Action: action,
ActionArg: uuid,
Options: &tabletmanagerdatapb.VDiffOptions{
ReportOptions: &tabletmanagerdatapb.VDiffReportOptions{
NoSamples: noSamples,
},
},
}
}
bothTargets := func(noSamples bool) map[*topodatapb.Tablet]*vdiffRequestResponse {
return map[*topodatapb.Tablet]*vdiffRequestResponse{
env.tablets[targetKeyspace.KeyspaceName][startingTargetTabletUID]: {req: expectedShowRequest(noSamples)},
env.tablets[targetKeyspace.KeyspaceName][startingTargetTabletUID+tabletUIDStep]: {req: expectedShowRequest(noSamples)},
}
}

tests := []struct {
name string
req *vtctldatapb.VDiffShowRequest
expectedVDiffRequests map[*topodatapb.Tablet]*vdiffRequestResponse
}{
{
name: "default forwards no_samples=false",
req: &vtctldatapb.VDiffShowRequest{
TargetKeyspace: targetKeyspace.KeyspaceName,
Workflow: workflow,
Arg: uuid,
},
expectedVDiffRequests: bothTargets(false),
},
{
name: "no_samples forwards no_samples=true",
req: &vtctldatapb.VDiffShowRequest{
TargetKeyspace: targetKeyspace.KeyspaceName,
Workflow: workflow,
Arg: uuid,
NoSamples: true,
},
expectedVDiffRequests: bothTargets(true),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for tab, vdr := range tt.expectedVDiffRequests {
env.tmc.expectVDiffRequest(tab, vdr)
}
got, err := env.ws.VDiffShow(ctx, tt.req)
require.NoError(t, err)
require.NotNil(t, got)
env.tmc.confirmVDiffRequests(t)
})
}
}
Loading
Loading