Skip to content

Commit

Permalink
fix: before exiting, make sure the goroutine has exited (#35411)
Browse files Browse the repository at this point in the history
#35409

Signed-off-by: fengjun2016 <[email protected]>
  • Loading branch information
fengjun2016 authored Aug 15, 2024
1 parent d20d6ea commit b4b1ed6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion internal/datanode/channel/channel_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,10 @@ func (r *opRunner) releaseWithTimer(releaseFunc releaseFunc, channel string, opI
}
}

finishWaiter.Add(1)
finishWaiter.Add(2)
go startTimer(&finishWaiter)
go func() {
defer finishWaiter.Done()
// TODO: failure should panic this DN, but we're not sure how
// to recover when releaseFunc stuck.
// Whenever we see a stuck, it's a bug need to be fixed.
Expand Down
8 changes: 3 additions & 5 deletions internal/datanode/channel/channel_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"os"
"testing"
"time"

"github.com/cockroachdb/errors"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -181,11 +182,10 @@ func (s *ChannelManagerSuite) TearDownTest() {

func (s *ChannelManagerSuite) TestReleaseStuck() {
var (
channel = "by-dev-rootcoord-dml-2"
stuckSig = make(chan struct{})
channel = "by-dev-rootcoord-dml-2"
)
s.manager.releaseFunc = func(channel string) {
stuckSig <- struct{}{}
time.Sleep(1 * time.Second)
}

info := GetWatchInfoByOpID(100, channel, datapb.ChannelWatchState_ToWatch)
Expand Down Expand Up @@ -215,8 +215,6 @@ func (s *ChannelManagerSuite) TestReleaseStuck() {
s.True(ok)
s.Equal(channel, abchannel)

<-stuckSig

resp := s.manager.GetProgress(releaseInfo)
s.Equal(datapb.ChannelWatchState_ReleaseFailure, resp.GetState())
}
Expand Down

0 comments on commit b4b1ed6

Please sign in to comment.