# Thread leaks in logstash-output-s3 when wrong access keys are passed

**URL:** <https://discuss.elastic.co/t/thread-leaks-in-logstash-output-s3-when-wrong-access-keys-are-passed/246657>\
**Category:** Logstash\
**Created:** [August 27, 2020, 3:39pm UTC](https://discuss.elastic.co/t/thread-leaks-in-logstash-output-s3-when-wrong-access-keys-are-passed/246657 "2020-08-27T15:39:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinaykambam](https://avatars.discourse-cdn.com/v4/letter/v/d9b06d/32.png) [@vinaykambam](https://discuss.elastic.co/u/vinaykambam)\
**Post date:** [August 27, 2020, 3:39pm UTC](https://discuss.elastic.co/t/thread-leaks-in-logstash-output-s3-when-wrong-access-keys-are-passed/246657/1 "2020-08-27T15:39:40Z")

</div>

Hi There,

I've observed thread leaks (S3, Stale factory sweeper) from logstash-output-s3 plugin when wrong access keys are passed in s3 output configuration. I tried same with different versions of logstash but it is the same in all the versions including latest 7.9.0

```auto
sh-4.2$ ps -eT | grep -i stale
   68 108 ? 00:00:01 S3, Stale facto
   68 303 ? 00:00:00 S3, Stale facto
   68 308 ? 00:00:00 S3, Stale facto
   68 316 ? 00:00:00 S3, Stale facto
   68 318 ? 00:00:00 S3, Stale facto
   68 320 ? 00:00:00 S3, Stale facto
   68 329 ? 00:00:00 S3, Stale facto
   68 331 ? 00:00:00 S3, Stale facto
   68 332 ? 00:00:00 S3, Stale facto
   68 333 ? 00:00:00 S3, Stale facto
   68 334 ? 00:00:00 S3, Stale facto
sh-4.2$ ps -eT | grep -i stale
   68 108 ? 00:00:01 S3, Stale facto
   68 303 ? 00:00:00 S3, Stale facto
   68 308 ? 00:00:00 S3, Stale facto
   68 316 ? 00:00:00 S3, Stale facto
   68 318 ? 00:00:00 S3, Stale facto
   68 320 ? 00:00:00 S3, Stale facto
   68 329 ? 00:00:00 S3, Stale facto
   68 331 ? 00:00:00 S3, Stale facto
   68 332 ? 00:00:00 S3, Stale facto
   68 333 ? 00:00:00 S3, Stale facto
   68 334 ? 00:00:00 S3, Stale facto
   68 353 ? 00:00:00 S3, Stale facto
   68 354 ? 00:00:00 S3, Stale facto
   68 365 ? 00:00:00 S3, Stale facto
   68 367 ? 00:00:00 S3, Stale facto
   68 368 ? 00:00:00 S3, Stale facto
   68 377 ? 00:00:00 S3, Stale facto
   68 379 ? 00:00:00 S3, Stale facto
   68 381 ? 00:00:00 S3, Stale facto
   68 382 ? 00:00:00 S3, Stale facto
   68 392 ? 00:00:00 S3, Stale facto
   68 393 ? 00:00:00 S3, Stale facto
   68 394 ? 00:00:00 S3, Stale facto
   68 404 ? 00:00:00 S3, Stale facto

```

When I started to look into the plugin code, the issue is more likely due to ruby concurrent call Class: Concurrent::TimerTask .  
If I understand code correctly, a new thread is created after the execution timeout to remove the inactive files from the map of files and those threads are not killed due to some reason

> <https://github.com/logstash-plugins/logstash-output-s3/blob/master/lib/logstash/outputs/s3/file_repository.rb>

I seem to have found a reported issue in concurrent-ruby

> <https://github.com/ruby-concurrency/concurrent-ruby/issues/639>
>
> For long-executing jobs and small execution\_interval values, TimerTask will leak threads at the rate of execution\_interval.
> timeout\_interval, whilst documented, doesn't seem to...

I'm not a programmer in ruby. Any help to avoid thread leaks would be appreciated.

If anyone else facing this kind of issue and knows of some workaround, please reply

Thanks,  
Vinay

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 24, 2020, 3:39pm UTC](https://discuss.elastic.co/t/thread-leaks-in-logstash-output-s3-when-wrong-access-keys-are-passed/246657/2 "2020-09-24T15:39:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
