Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vtctld Workflow Command: fix error state in Workflow Show #6970

Merged
merged 2 commits into from
Oct 30, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func TestPlayerStatementModeWithFilter(t *testing.T) {
output := []string{
"begin",
"rollback",
"/update _vt.vreplication set message='filter rules are not supported for SBR",
"/update _vt.vreplication set message='Error: filter rules are not supported for SBR",
}

execStatements(t, input)
Expand Down Expand Up @@ -1429,7 +1429,7 @@ func TestPlayerDDL(t *testing.T) {
execStatements(t, []string{"alter table t1 add column val2 varchar(128)"})
expectDBClientQueries(t, []string{
"alter table t1 add column val2 varchar(128)",
"/update _vt.vreplication set message='Duplicate",
"/update _vt.vreplication set message='Error: Duplicate",
})
cancel()

Expand Down Expand Up @@ -2165,7 +2165,7 @@ func TestRestartOnVStreamEnd(t *testing.T) {

streamerEngine.Close()
expectDBClientQueries(t, []string{
"/update _vt.vreplication set message='vstream ended'",
"/update _vt.vreplication set message='Error: vstream ended'",
})
streamerEngine.Open()

Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletmanager/vreplication/vreplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (vr *vreplicator) Replicate(ctx context.Context) error {
err := vr.replicate(ctx)
if err != nil {
log.Errorf("Replicate error: %s", err.Error())
if err := vr.setMessage(err.Error()); err != nil {
if err := vr.setMessage(fmt.Sprintf("Error: %s", err.Error())); err != nil {
log.Errorf("Failed to set error state: %v", err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion go/vt/wrangler/vexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func (wr *Wrangler) ShowWorkflow(ctx context.Context, workflow, keyspace string)
}

func updateState(message, state string, cs []copyState, timeUpdated int64) string {
if message != "" {
if strings.Contains(strings.ToLower(message), "error") {
state = "Error"
} else if state == "Running" && len(cs) > 0 {
state = "Copying"
Expand Down
4 changes: 3 additions & 1 deletion go/vt/wrangler/vexec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ func TestVExec(t *testing.T) {
}

func TestWorkflowStatusUpdate(t *testing.T) {
require.Equal(t, "Error", updateState("master tablet not contactable", "Running", nil, 0))
require.Equal(t, "Running", updateState("for vdiff", "Running", nil, int64(time.Now().Second())))
require.Equal(t, "Running", updateState("", "Running", nil, int64(time.Now().Second())))
require.Equal(t, "Lagging", updateState("", "Running", nil, int64(time.Now().Second())-100))
require.Equal(t, "Copying", updateState("", "Running", []copyState{{Table: "t1", LastPK: "[[INT64(10)]]"}}, int64(time.Now().Second())))
require.Equal(t, "Error", updateState("error: master tablet not contactable", "Running", nil, 0))
}

func TestWorkflowListStreams(t *testing.T) {
Expand Down