fix: preserve cross-pod message order

This commit is contained in:
richjohnrambo
2026-10-01 19:00:16 +08:00
parent dccd0969d8
commit d43b1b63d3
8 changed files with 222 additions and 12 deletions
+4 -1
View File
@@ -168,6 +168,9 @@ type Session struct {
// Type of proxy to master request being handled.
proxyReq ProxyReqType
// Ensures that one multiplexing session is drained by at most one cluster
// write task at a time, preserving per-topic response order.
clusterWriteScheduled atomic.Bool
}
// Subscription is a mapper of sessions to topics.
@@ -332,7 +335,7 @@ func (s *Session) isCluster() bool {
}
func (s *Session) scheduleClusterWriteLoop() {
if globals.cluster != nil && globals.cluster.proxyEventQueue != nil {
if globals.cluster != nil && globals.cluster.proxyEventQueue != nil && s.clusterWriteScheduled.CompareAndSwap(false, true) {
globals.cluster.proxyEventQueue.Schedule(
func() { s.clusterWriteLoop(s.proxiedTopic) })
}