File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
plugins/outputs/cloudwatchlogs Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -89,12 +89,16 @@ func (c *CloudWatchLogs) Connect() error {
8989}
9090
9191func (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 }
You can’t perform that action at this time.
0 commit comments