Skip to content

Commit

Permalink
VReplication: Fix workflow update changed handling (#15621)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord authored Apr 3, 2024
1 parent 60eafac commit 0e2f175
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 175 deletions.
1 change: 0 additions & 1 deletion go/cmd/vtctldclient/command/vreplication/workflow/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func commandUpdateState(cmd *cobra.Command, args []string) error {
TabletTypes: []topodatapb.TabletType{topodatapb.TabletType(textutil.SimulatedNullInt)},
OnDdl: binlogdatapb.OnDDLAction(textutil.SimulatedNullInt),
State: state,
Shards: baseOptions.Shards,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func commandUpdate(cmd *cobra.Command, args []string) error {
TabletTypes: updateOptions.TabletTypes,
TabletSelectionPreference: tsp,
OnDdl: binlogdatapb.OnDDLAction(onddl),
Shards: baseOptions.Shards,
State: binlogdatapb.VReplicationWorkflowState(textutil.SimulatedNullInt), // We don't allow changing this in the client command
},
}

Expand Down
1 change: 1 addition & 0 deletions go/test/endtoend/vreplication/multi_tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func TestMultiTenantSimple(t *testing.T) {
for _, ks := range []string{sourceKeyspace, sourceAliasKeyspace} {
lastIndex = insertRows(lastIndex, ks)
}
waitForWorkflowState(t, vc, fmt.Sprintf("%s.%s", targetKeyspace, mt.workflowName), binlogdatapb.VReplicationWorkflowState_Running.String())
mt.SwitchReadsAndWrites()
validateKeyspaceRoutingRules(t, vc, primaries, rulesMap, true)
// Note: here we have already switched and we can insert into the target keyspace and it should get reverse
Expand Down
31 changes: 28 additions & 3 deletions go/test/endtoend/vreplication/resharding_workflows_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/encoding/protojson"

"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/wrangler"

binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata"
)

const (
Expand Down Expand Up @@ -212,19 +214,42 @@ func tstWorkflowComplete(t *testing.T) error {
// to primary,replica,rdonly (the only applicable types in these tests).
func testWorkflowUpdate(t *testing.T) {
tabletTypes := "primary,replica,rdonly"
// Test vtctlclient first
// Test vtctlclient first.
_, err := vc.VtctlClient.ExecuteCommandWithOutput("workflow", "--", "--tablet-types", tabletTypes, "noexist.noexist", "update")
require.Error(t, err, err)
resp, err := vc.VtctlClient.ExecuteCommandWithOutput("workflow", "--", "--tablet-types", tabletTypes, ksWorkflow, "update")
require.NoError(t, err)
require.NotEmpty(t, resp)

// Test vtctldclient last
// Test vtctldclient last.
_, err = vc.VtctldClient.ExecuteCommandWithOutput("workflow", "--keyspace", "noexist", "update", "--workflow", "noexist", "--tablet-types", tabletTypes)
require.Error(t, err)
// Change the tablet-types to rdonly.
resp, err = vc.VtctldClient.ExecuteCommandWithOutput("workflow", "--keyspace", targetKs, "update", "--workflow", workflowName, "--tablet-types", "rdonly")
require.NoError(t, err, err)
// Confirm that we changed the workflow.
var ures vtctldatapb.WorkflowUpdateResponse
require.NoError(t, err)
err = protojson.Unmarshal([]byte(resp), &ures)
require.NoError(t, err)
require.Greater(t, len(ures.Details), 0)
require.True(t, ures.Details[0].Changed)
// Change tablet-types back to primary,replica,rdonly.
resp, err = vc.VtctldClient.ExecuteCommandWithOutput("workflow", "--keyspace", targetKs, "update", "--workflow", workflowName, "--tablet-types", tabletTypes)
require.NoError(t, err, err)
require.NotEmpty(t, resp)
// Confirm that we changed the workflow.
err = protojson.Unmarshal([]byte(resp), &ures)
require.NoError(t, err)
require.Greater(t, len(ures.Details), 0)
require.True(t, ures.Details[0].Changed)
// Execute a no-op as tablet-types is already primary,replica,rdonly.
resp, err = vc.VtctldClient.ExecuteCommandWithOutput("workflow", "--keyspace", targetKs, "update", "--workflow", workflowName, "--tablet-types", tabletTypes)
require.NoError(t, err, err)
// Confirm that we didn't change the workflow.
err = protojson.Unmarshal([]byte(resp), &ures)
require.NoError(t, err)
require.Greater(t, len(ures.Details), 0)
require.False(t, ures.Details[0].Changed)
}

func tstWorkflowCancel(t *testing.T) error {
Expand Down
139 changes: 71 additions & 68 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.

Loading

0 comments on commit 0e2f175

Please sign in to comment.