Skip to content

Commit c3d5e69

Browse files
committed
Revert "docs: Remove stale shutdown order comments"
This reverts commit 7360649.
1 parent 7360649 commit c3d5e69

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

plugins/outputs/cloudwatchlogs/cloudwatchlogs.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ func (c *CloudWatchLogs) Connect() error {
8989
}
9090

9191
func (c *CloudWatchLogs) Close() error {
92-
// Shutdown order:
93-
// 1. Stop pushers (queues + senders) — no new batches created
94-
// 2. Wait for pushers to complete
95-
// 3. Stop RetryHeapProcessor — flush remaining batches, stop sender pool
96-
// 4. Stop WorkerPool — no more worker threads
97-
// 5. Stop RetryHeap — final cleanup
92+
// Stop components in specific order to prevent race conditions:
93+
// 1. RetryHeap - stop accepting new batches first
94+
// 2. Pushers - stop all active pushers (queues/senders)
95+
// 3. Wait for pushers to complete
96+
// 4. RetryHeapProcessor - stop retry processing and wait for WorkerPool usage to complete
97+
// 5. WorkerPool - finally stop the worker threads
98+
99+
if c.retryHeap != nil {
100+
c.retryHeap.Stop()
101+
}
98102

99103
c.cwDests.Range(func(_, value interface{}) bool {
100104
if d, ok := value.(*cwDest); ok {
@@ -113,6 +117,10 @@ func (c *CloudWatchLogs) Close() error {
113117
c.workerPool.Stop()
114118
}
115119

120+
if c.retryHeapProcessor != nil {
121+
c.retryHeapProcessor.Stop()
122+
}
123+
116124
if c.retryHeap != nil {
117125
c.retryHeap.Stop()
118126
}

0 commit comments

Comments
 (0)