diff --git a/platform/extension/messagequeue/mysql/sql.go b/platform/extension/messagequeue/mysql/sql.go index d9834a2ed..5e555efe0 100644 --- a/platform/extension/messagequeue/mysql/sql.go +++ b/platform/extension/messagequeue/mysql/sql.go @@ -54,8 +54,10 @@ type Params struct { // MetricsScope for metrics collection (required) MetricsScope tally.Scope - // OnSignal receives typed subscriber lifecycle signals (HookSignal). - // Nil in production; used by integration tests for event-driven waits. + // OnSignal lets tests wait on subscriber cycles without sleeping: one + // HookSignal per completed delivery check or ownership pass. Not for + // production: signals carry no data and are dropped while the channel is + // full (see emitSignal), so never treat one as a specific event or count them. OnSignal chan HookSignal // Tenants is the configured shard isolation list. Empty permits publishing diff --git a/platform/extension/messagequeue/mysql/subscriber.go b/platform/extension/messagequeue/mysql/subscriber.go index f31455d31..d1aea353f 100644 --- a/platform/extension/messagequeue/mysql/subscriber.go +++ b/platform/extension/messagequeue/mysql/subscriber.go @@ -121,8 +121,7 @@ type subscriber struct { subscriptions map[string]*subscription subMu sync.Mutex - // OnSignal receives typed lifecycle signals. Nil in production. - // Consumers filter by signal type to wait for specific events. + // OnSignal receives typed lifecycle signals. Nil in production; see emitSignal. OnSignal chan HookSignal } @@ -455,12 +454,14 @@ func NewSubscriber(logger *zap.SugaredLogger, scope tally.Scope, messageStore me } } -// emitSignal sends a signal on OnSignal if set. Blocks until the signal is -// received, allowing tests to synchronize by controlling when signals are drained. -// Production code does not set OnSignal, so this is a no-op outside tests. +// emitSignal drops sig while OnSignal is full: an unread hook must never stall +// a worker or the supervisor, so a receiver learns "at least one", not "every". func (s *subscriber) emitSignal(sig HookSignal) { if ch := s.OnSignal; ch != nil { - ch <- sig + select { + case ch <- sig: + default: + } } } diff --git a/test/integration/extension/messagequeue/mysql/README.md b/test/integration/extension/messagequeue/mysql/README.md index a340116b7..f298f54c2 100644 --- a/test/integration/extension/messagequeue/mysql/README.md +++ b/test/integration/extension/messagequeue/mysql/README.md @@ -31,6 +31,8 @@ Tests use **zero `time.Sleep` calls**. Instead, they use the subscriber's `OnSig | `SignalDeliveryCheck` | A partition was checked for deliverable messages (including watermark advancement) | | `SignalPartitionUpdate` | Partition ownership was evaluated (discovery, rebalance, lease renewal) | +Emission never blocks: a signal is dropped while the channel is full, so a received signal means at least one such event completed since the channel was last drained. + Signal names describe behavioral concerns, not implementation details, so they remain stable across internal refactors. ### Test helpers diff --git a/test/integration/extension/messagequeue/mysql/queue_test.go b/test/integration/extension/messagequeue/mysql/queue_test.go index d8a07e07a..6e143ef94 100644 --- a/test/integration/extension/messagequeue/mysql/queue_test.go +++ b/test/integration/extension/messagequeue/mysql/queue_test.go @@ -2321,8 +2321,6 @@ func (s *SQLQueueIntegrationSuite) TestGCReclaimsAckedRowsUnderContinuousTraffic testMessage(fmt.Sprintf("gc-busy-%d", i), []byte("y"), partition, nil))) delivery := receive(t, deliveryChan) require.NoError(t, delivery.Ack(s.ctx)) - // Drain signals so the worker's blocking send cannot stall the traffic loop. - drainSignals(signalCh) } waitForCondition(t, signalCh, func() bool {