Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RAS plugin - fix for too many open files handlers #8306

Merged
merged 2 commits into from
Oct 23, 2020

Conversation

p-zak
Copy link
Collaborator

@p-zak p-zak commented Oct 23, 2020

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

Details

Database driver doesn't close file handler properly when db.Close() is called.
This may lead to too many open files for Telegraf process (returned by OS).

In this fix sql.Open() is called once in Start() and db.Close() is also called only once in Stop().

This is also optimization (open DB just once, not in every Gather()) and following along guide from comment for func (db *DB) Close() error in sql.go:

// It is rare to Close a DB, as the DB handle is meant to be
// long-lived and shared between many goroutines.

The same approach was introduced in inputs/postgresql plugin.

plugins/inputs/ras/ras.go Outdated Show resolved Hide resolved
@ssoroka ssoroka merged commit 6923001 into influxdata:master Oct 23, 2020
ssoroka pushed a commit that referenced this pull request Oct 28, 2020
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants