beatenevo commented on code in PR #1180:
URL:
https://github.com/apache/incubator-seata-go/pull/1180#discussion_r4031836293
##########
pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler.go:
##########
@@ -204,18 +223,18 @@ func (handler *tccFenceWrapperHandler)
InitLogCleanChannel(dsn string) {
}
handler.logQueueOnce.Do(func() {
- handler.backgroundWg.Add(1)
+ handler.cleanerWg.Add(1)
go func() {
- defer handler.backgroundWg.Done()
+ defer handler.cleanerWg.Done()
handler.traversalCleanChannel(db)
}()
})
handler.logTaskOnce.Do(func() {
handler.stopLogCleanTask = make(chan struct{})
- handler.backgroundWg.Add(1)
+ handler.logTaskWg.Add(1)
go func() {
- defer handler.backgroundWg.Done()
+ defer handler.logTaskWg.Done()
handler.initLogCleanTask(db)
}()
})
Review Comment:
The deferred `lifecycleMutex.Unlock()` runs only when
`InitLogCleanChannel()` returns, so the lock covers channel initialization,
`WaitGroup.Add()`, and goroutine startup, preventing them from racing with
`DestroyLogCleanChannel()` calls to `Wait()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]