311
// Stop does not unload the queue from its partition. It is intended to be called by the partition manager when
312
// unloading a queues. For stopping and unloading a queue call UnloadFromPartitionManager instead.
314
>
if !atomic.CompareAndSwapInt32(
315
>
&c.status,
316
>
common.DaemonStatusStarted,
317
>
common.DaemonStatusStopped,
318
>
) {
319
return
320
}
321
// this may attempt to write one final ack update, do this before canceling tqCtx
323
>
if m := c.getDrainBacklogMgr(); m != nil {
324
m.Stop()
325
}
327
>
c.liveness.Stop()
328
>
c.tqCtxCancel()
329
>
330
>
// Emitting zero values for backlog gauges to prevent stale values persisting after a partition is unloaded.
331
>
// The call is placed here instead of backlogMgr.Stop() since there could be a race condition where a task is
332
>
// added to the backlog after we have emitted the zero values inside of the backlogMgr.Stop() call. This happens
333
>
// since task reader's and writer's contexts are cancelled after the backlogMgr.Stop() call.
334
>
c.backlogMgr.getDB().emitZeroPhysicalBacklogGauges()
335
>
c.logger.Info("Stopped physicalTaskQueueManager", tag.LifeCycleStopped, tag.Cause(unloadCause.String()))
336
>
c.metricsHandler.Counter(metrics.TaskQueueStoppedCounter.Name()).Record(1)
337
>
c.partitionMgr.engine.updatePhysicalTaskQueueGauge(c.partitionMgr.ns, c.partitionMgr.partition, c.queue.version, -1)
338
}
339