Skip to content

Fix memory leak in couchbase input#9544

Merged
MyaLongmire merged 2 commits intoinfluxdata:masterfrom
akrantz01:9495-couchbase-leak
Sep 7, 2021
Merged

Fix memory leak in couchbase input#9544
MyaLongmire merged 2 commits intoinfluxdata:masterfrom
akrantz01:9495-couchbase-leak

Conversation

@akrantz01
Copy link
Copy Markdown
Contributor

Required for all PRs:

  • Updated associated README.md
  • Wrote appropriate unit tests.

resolves #9495

Fixes a memory leak in the couchbase plugin by closing all pools after they are done being used. The leak showed up after updating to go-couchbase v0.1.0 in #9412. It appears to be caused by circular references between buckets and their corresponding pools (I think this is the cause, I'm not entirely sure though).

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Jul 26, 2021
@akrantz01 akrantz01 changed the title 9495 couchbase leak Fix memory leak in couchbase input Jul 26, 2021
if err != nil {
return err
}
defer pool.Close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we close the pool and not the connection? Also shouldn't we be reusing both?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we would be reusing both. However, if we reuse the pool, there is no way to refresh the bucket map, so we wouldn't be able to get metrics for new buckets, and we would start erroring if a bucket gets deleted.

We don't close the connection because there isn't a method to do that.

@MyaLongmire MyaLongmire merged commit ba1484c into influxdata:master Sep 7, 2021
reimda pushed a commit that referenced this pull request Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/couchbase fix pr to fix corresponding bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegraf 1.19 lack of memory with couchbase plugin

3 participants