Skip to content

Commit

Permalink
owner(ticdc): Fix a nil pointer access bug when appending DataPatches (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Apr 15, 2022
1 parent 2746528 commit 5f5fc58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cdc/owner/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ func (c *changefeed) updateStatus(currentTs int64, barrierTs model.Ts) {
}
c.state.PatchStatus(func(status *model.ChangeFeedStatus) (*model.ChangeFeedStatus, bool, error) {
changed := false
if status == nil {
return nil, changed, nil
}
if status.ResolvedTs != resolvedTs {
status.ResolvedTs = resolvedTs
changed = true
Expand Down
12 changes: 12 additions & 0 deletions cdc/owner/feed_state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ func (m *feedStateManager) handleAdminJob() (jobsPending bool) {
m.patchState(model.StateNormal)
// remove error history to make sure the changefeed can running in next tick
m.state.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
if info == nil {
return nil, false, nil
}
if info.Error != nil || len(info.ErrorHis) != 0 {
info.Error = nil
info.ErrorHis = nil
Expand Down Expand Up @@ -199,6 +202,9 @@ func (m *feedStateManager) patchState(feedState model.FeedState) {
})
m.state.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
changed := false
if info == nil {
return nil, changed, nil
}
if info.State != feedState {
info.State = feedState
changed = true
Expand Down Expand Up @@ -263,6 +269,9 @@ func (m *feedStateManager) handleError(errs ...*model.RunningError) {
for _, err := range errs {
if cerrors.ChangefeedFastFailErrorCode(errors.RFCErrorCode(err.Code)) {
m.state.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
if info == nil {
return nil, false, nil
}
info.Error = err
info.ErrorHis = append(info.ErrorHis, time.Now().UnixNano()/1e6)
info.CleanUpOutdatedErrorHistory()
Expand All @@ -275,6 +284,9 @@ func (m *feedStateManager) handleError(errs ...*model.RunningError) {
}

m.state.PatchInfo(func(info *model.ChangeFeedInfo) (*model.ChangeFeedInfo, bool, error) {
if info == nil {
return nil, false, nil
}
for _, err := range errs {
info.Error = err
info.ErrorHis = append(info.ErrorHis, time.Now().UnixNano()/1e6)
Expand Down

0 comments on commit 5f5fc58

Please sign in to comment.