Skip to content

Commit

Permalink
api(ticdc): Not show the error info during query the changefeed when …
Browse files Browse the repository at this point in the history
…state is stopped, finished and removed (#11641)

close #11642
  • Loading branch information
hongyunyan authored Oct 16, 2024
1 parent 32b27ca commit 62d07b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions cdc/api/v2/changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (h *OpenAPIV2) listChangeFeeds(c *gin.Context) {

// if the state is normal, we shall not return the error info
// because changefeed will is retrying. errors will confuse the users
if commonInfo.FeedState == model.StateNormal {
if !shouldShowRunningError(commonInfo.FeedState) {
commonInfo.RunningError = nil
}

Expand Down Expand Up @@ -1025,6 +1025,15 @@ func (h *OpenAPIV2) synced(c *gin.Context) {
})
}

func shouldShowRunningError(state model.FeedState) bool {
switch state {
case model.StateNormal, model.StateStopped, model.StateFinished, model.StateRemoved:
return false
default:
return true
}
}

func toAPIModel(
info *model.ChangeFeedInfo,
resolvedTs uint64,
Expand All @@ -1036,7 +1045,7 @@ func toAPIModel(

// if the state is normal, we shall not return the error info
// because changefeed will is retrying. errors will confuse the users
if info.State != model.StateNormal && info.Error != nil {
if info.Error != nil && shouldShowRunningError(info.State) {
runningError = &RunningError{
Addr: info.Error.Addr,
Code: info.Error.Code,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/changefeed_error/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function run() {
run_cdc_cli changefeed create --start-ts=0 --sink-uri="$SINK_URI" -c $changefeedid_3
ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1}:${UP_PD_PORT_1} ${changefeedid_3} "normal" "null" ""
run_cdc_cli changefeed pause -c $changefeedid_3
ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1}:${UP_PD_PORT_1} ${changefeedid_3} "stopped" "changefeed new redo manager injected error" ""
ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1}:${UP_PD_PORT_1} ${changefeedid_3} "stopped" "null" ""
run_cdc_cli changefeed resume -c $changefeedid_3
ensure $MAX_RETRIES check_changefeed_state http://${UP_PD_HOST_1}:${UP_PD_PORT_1} ${changefeedid_3} "normal" "null" ""
run_cdc_cli changefeed remove -c $changefeedid_3
Expand Down

0 comments on commit 62d07b5

Please sign in to comment.