Skip to content
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
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ func (node *AlgorandFullNode) AbortCatchup(catchpoint string) error {
// channel which contains the updated node context. This function need to work asynchronously so that the caller could
// detect and handle the use case where the node is being shut down while we're switching to/from catchup mode without
// deadlocking on the shared node mutex.
func (node *AlgorandFullNode) SetCatchpointCatchupMode(catchpointCatchupMode bool) (outCtxCh <-chan context.Context) {
func (node *AlgorandFullNode) SetCatchpointCatchupMode(enable bool) (outCtxCh <-chan context.Context) {
// create a non-buffered channel to return the newly created context. The fact that it's non-buffered here
// is important, as it allows us to synchronize the "receiving" of the new context before canceling of the previous
// one.
Expand All @@ -1262,7 +1262,7 @@ func (node *AlgorandFullNode) SetCatchpointCatchupMode(catchpointCatchupMode boo
node.mu.Unlock()
return
}
if catchpointCatchupMode {
if enable {
// stop..
defer func() {
node.mu.Unlock()
Expand Down
4 changes: 4 additions & 0 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,10 @@ func TestNodeSetCatchpointCatchupMode(t *testing.T) {
// "start" catchpoint catchup => close services
outCh := n.SetCatchpointCatchupMode(true)
<-outCh
// make sure SetCatchpointCatchupMode' goroutine has completely finished
// to prevent data race on stop/start services
n.waitMonitoringRoutines()

// "stop" catchpoint catchup => resume services
outCh = n.SetCatchpointCatchupMode(false)
<-outCh
Expand Down
Loading