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 Feb 21, 2022
1 parent 52f828f commit 648ce2c
Show file tree
Hide file tree
Showing 2 changed files with 12 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 @@ -501,6 +501,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
9 changes: 9 additions & 0 deletions cdc/owner/feed_state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,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 @@ -364,6 +367,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
return info, true, nil
})
Expand All @@ -374,6 +380,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
}
Expand Down

0 comments on commit 648ce2c

Please sign in to comment.