fix: stop writes to closed cluster sessions

This commit is contained in:
richjohnrambo
2026-10-02 00:28:02 +08:00
parent d43b1b63d3
commit a406d63154
3 changed files with 98 additions and 0 deletions
+5
View File
@@ -1398,6 +1398,11 @@ func (sess *Session) clusterWriteLoop(forTopic string) {
terminate := true
defer func() {
if terminate {
// The topic may retain this multiplexing session briefly while its
// unsubscribe request is processed. Reject writes to the stale session
// instead of filling a send queue which no longer has a drain owner.
atomic.StoreInt32(&sess.terminating, 1)
sess.purgeChannels()
sess.closeRPC()
globals.sessionStore.Delete(sess)
sess.inflightReqs = nil