Skip to content

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

Merged
ssoroka merged 2 commits intoinfluxdata:masterfrom
p-zak:ras_db_fix
Oct 23, 2020
Merged

RAS plugin - fix for too many open files handlers#8306
ssoroka merged 2 commits intoinfluxdata:masterfrom
p-zak:ras_db_fix

Conversation

@p-zak
Copy link
Copy Markdown
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.

@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