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

owner(ticdc): Fix a nil pointer access bug when appending DataPatches (#4085) #4182

Merged
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
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