Re: [PR] Fix client shutdown deadlock [dubbo-getty]
AlexStocks merged PR #142: URL: https://github.com/apache/dubbo-getty/pull/142 -- 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]
Re: [PR] Fix client shutdown deadlock [dubbo-getty]
222twotwotwo commented on code in PR #142:
URL: https://github.com/apache/dubbo-getty/pull/142#discussion_r3801678617
##
client.go:
##
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession
NewSessionCallback) {
c.Lock()
c.newSession = newSession
c.Unlock()
- c.reConnect()
+ <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+ done := make(chan struct{})
+ c.Lock()
+ select {
+ case <-c.done:
+ c.Unlock()
+ close(done)
+ return done
+ default:
+ c.wg.Add(1)
+ }
+ c.Unlock()
+
+ go func() {
+ defer c.wg.Done()
+ defer close(done)
+ c.reConnect()
+ }()
Review Comment:
收到,已为重连循环引入 single‑flight 机制;同时新增回归测试
--
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]
Re: [PR] Fix client shutdown deadlock [dubbo-getty]
AlexStocks commented on code in PR #142:
URL: https://github.com/apache/dubbo-getty/pull/142#discussion_r3791614016
##
client.go:
##
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession
NewSessionCallback) {
c.Lock()
c.newSession = newSession
c.Unlock()
- c.reConnect()
+ <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+ done := make(chan struct{})
+ c.Lock()
+ select {
+ case <-c.done:
+ c.Unlock()
+ close(done)
+ return done
+ default:
+ c.wg.Add(1)
+ }
+ c.Unlock()
+
+ go func() {
+ defer c.wg.Done()
+ defer close(done)
+ c.reConnect()
+ }()
Review Comment:
[P1] 并发重连确定会突破连接池上限
当前 Head `1994e7cf2f5dd40d24da00e3d7a9b587f45dc18f` 的确定性探针让两个
`runReconnect()` 同时通过 `newSession` barrier;在 `WithConnectionNumber(1)` 下释放后
`len(ssMap)` 为 2。根因正是 `sessionNum()` 检查与 `ssMap` 插入分属不同临界区。请对重连 loop 做
single-flight/串行化,并补并发触发仍严格遵守 pool limit 的回归测试。
--
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]
Re: [PR] Fix client shutdown deadlock [dubbo-getty]
222twotwotwo commented on code in PR #142:
URL: https://github.com/apache/dubbo-getty/pull/142#discussion_r3791268163
##
client.go:
##
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession
NewSessionCallback) {
c.Lock()
c.newSession = newSession
c.Unlock()
- c.reConnect()
+ <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+ done := make(chan struct{})
+ c.Lock()
+ select {
+ case <-c.done:
+ c.Unlock()
+ close(done)
+ return done
+ default:
+ c.wg.Add(1)
Review Comment:
收到, NewSessionCallback`内调用 Client.Close() 时不会再等待当前正在执行 callback 的 goroutine
自己。
##
client.go:
##
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession
NewSessionCallback) {
c.Lock()
c.newSession = newSession
c.Unlock()
- c.reConnect()
+ <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+ done := make(chan struct{})
+ c.Lock()
+ select {
+ case <-c.done:
+ c.Unlock()
+ close(done)
+ return done
+ default:
+ c.wg.Add(1)
Review Comment:
收到, NewSessionCallback内调用 Client.Close() 时不会再等待当前正在执行 callback 的 goroutine
自己。
--
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]
Re: [PR] Fix client shutdown deadlock [dubbo-getty]
Copilot commented on code in PR #142:
URL: https://github.com/apache/dubbo-getty/pull/142#discussion_r3782358854
##
client.go:
##
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession
NewSessionCallback) {
c.Lock()
c.newSession = newSession
c.Unlock()
- c.reConnect()
+ <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+ done := make(chan struct{})
+ c.Lock()
+ select {
+ case <-c.done:
+ c.Unlock()
+ close(done)
+ return done
+ default:
+ c.wg.Add(1)
+ }
+ c.Unlock()
+
+ go func() {
+ defer c.wg.Done()
+ defer close(done)
+ c.reConnect()
+ }()
Review Comment:
runReconnect starts a new goroutine on every call (go func { ...
c.reConnect() }), but it doesn’t deduplicate concurrent triggers. If multiple
sessions call runReconnect around the same time, multiple reConnect loops can
run concurrently and race to create connections. Because the pool-size check
(sessionNum) and the add to ssMap happen in separate critical sections,
concurrent loops can overshoot c.number and create more sessions than
configured.
Consider guarding reconnect with a single-flight mechanism (e.g., a
reconnectRunning atomic flag / channel) so only one reconnect loop runs at a
time, and subsequent triggers become no-ops while a reconnect is in flight.
--
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]
Re: [PR] Fix client shutdown deadlock [dubbo-getty]
AlexStocks commented on code in PR #142:
URL: https://github.com/apache/dubbo-getty/pull/142#discussion_r3782342254
##
client.go:
##
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession
NewSessionCallback) {
c.Lock()
c.newSession = newSession
c.Unlock()
- c.reConnect()
+ <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+ done := make(chan struct{})
+ c.Lock()
+ select {
+ case <-c.done:
+ c.Unlock()
+ close(done)
+ return done
+ default:
+ c.wg.Add(1)
Review Comment:
[P1] 这里把整个重连 goroutine 计入 `wg` 后,`NewSessionCallback` 内调用公开的
`Client.Close()` 会等待当前 goroutine 自己,形成确定性死锁。固定 Base/Head 的公开入口探针中,Base 在回调调用
`Close()` 并返回错误后正常退出;当前 Head 在 500ms 内始终无法返回。回调文档没有禁止关闭所属
endpoint,这类连接校验失败后主动停机的用法不能被锁死。请避免让 `Close()` 等待正在执行该回调的 worker(例如把停止信号与外部 join
分离,或调整重连任务的生命周期登记),并补一个回调内关闭客户端的回归测试。
--
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]
Re: [PR] Fix client shutdown deadlock [dubbo-getty]
222twotwotwo closed pull request #141: Fix client shutdown deadlock URL: https://github.com/apache/dubbo-getty/pull/141 -- 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]
