Skip to content

Commit

Permalink
processor(ticdc): Fix processor panic issue (#10922)
Browse files Browse the repository at this point in the history
close #10921
  • Loading branch information
sdojjy authored Apr 18, 2024
1 parent c8ed99f commit 0ffc857
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cdc/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,10 @@ func (p *processor) cleanupMetrics() {

// WriteDebugInfo write the debug info to Writer
func (p *processor) WriteDebugInfo(w io.Writer) error {
if !p.initialized.Load() {
fmt.Fprintln(w, "processor is not initialized")
return nil
}
fmt.Fprintf(w, "%+v\n%+v\n", *p.latestInfo, *p.latestStatus)
spans := p.sinkManager.r.GetAllCurrentTableSpans()
for _, span := range spans {
Expand Down
8 changes: 8 additions & 0 deletions cdc/processor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"encoding/json"
"fmt"
"math"
"os"
"sync/atomic"
"testing"

Expand Down Expand Up @@ -795,3 +796,10 @@ func TestProcessorDostNotStuckInInit(t *testing.T) {
require.Nil(t, p.Close())
tester.MustApplyPatches()
}

func TestProcessorNotInitialized(t *testing.T) {
globalVars, changefeedVars := vars.NewGlobalVarsAndChangefeedInfo4Test()
liveness := model.LivenessCaptureAlive
p, _, _ := initProcessor4Test(t, &liveness, false, globalVars, changefeedVars)
require.Nil(t, p.WriteDebugInfo(os.Stdout))
}

0 comments on commit 0ffc857

Please sign in to comment.