Skip to content

Commit

Permalink
owner(ticdc): fix changefeed state is automatically changed bug (#8331)
Browse files Browse the repository at this point in the history
close #8330
  • Loading branch information
sdojjy authored Feb 23, 2023
1 parent b4a7f0a commit 77d2c22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cdc/owner/feed_state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ func (m *feedStateManager) handleError(errs ...*model.RunningError) {
}
}

// changefeed state from stopped to failed is allowed
// but stopped to error or normal is not allowed
if m.state.Info != nil && m.state.Info.State == model.StateStopped {
log.Warn("changefeed is stopped, ignore errors",
zap.String("changefeed", m.state.ID.ID),
zap.String("namespace", m.state.ID.Namespace),
zap.Any("errors", errs))
return
}

// we need to patch changefeed unretryable error to the changefeed info,
// so we have to iterate all errs here to check wether it is a unretryable
// error in errs
Expand Down
17 changes: 17 additions & 0 deletions cdc/owner/feed_state_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,23 @@ func TestHandleFastFailError(t *testing.T) {
tester.MustApplyPatches()
}

func TestHandleErrorWhenChangefeedIsPaused(t *testing.T) {
ctx := cdcContext.NewBackendContext4Test(true)
manager := newFeedStateManager4Test(0, 0, 0, 0)
manager.state = orchestrator.NewChangefeedReactorState(etcd.DefaultCDCClusterID,
ctx.ChangefeedVars().ID)
err := &model.RunningError{
Addr: ctx.GlobalVars().CaptureInfo.AdvertiseAddr,
Code: "CDC:ErrReachMaxTry",
Message: "fake error for test",
}
manager.state.Info = &model.ChangeFeedInfo{
State: model.StateStopped,
}
manager.handleError(err)
require.Equal(t, model.StateStopped, manager.state.Info.State)
}

func TestChangefeedStatusNotExist(t *testing.T) {
changefeedInfo := `
{
Expand Down

0 comments on commit 77d2c22

Please sign in to comment.