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

API requests to endpoint "/api/v2/backup/metadata" result in file handle resource leakage #24366

Open
cbainlive opened this issue Sep 12, 2023 · 2 comments

Comments

@cbainlive
Copy link

Steps to reproduce:

  1. Run command sudo lsof -p `pidof influxd` | grep deleted | wc -l and note the count of deleted file handles held open by influxd
  2. Run curl "http://localhost:8086/api/v2/backup/metadata" -XGET --header "Authorization: Token $TOKEN" --output response to hit the API endpoint
  3. Re-run command sudo lsof -p `pidof influxd` | grep deleted | wc -l and note count has increased by 1

For example:

influxdb@localhost> uname -srm
Linux 5.4.0-148-generic x86_64
influxdb@localhost> influxd version
InfluxDB v2.6.1 (git: 9dcf880fe0) build_date: 2022-12-29T15:53:07Z
influxdb@localhost> sudo lsof -p `pidof influxd` | grep deleted | wc -l
0
influxdb@localhost> curl "http://localhost:8086/api/v2/backup/metadata" -XGET --header "Authorization: Token $TOKEN" --output response
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  278k    0  278k    0     0  22.6M      0 --:--:-- --:--:-- --:--:-- 22.6M
influxdb@localhost> sudo lsof -p `pidof influxd` | grep deleted | wc -l
1

Expected behavior:
The influxd process should clean up resources after completing processing of the API request.

Actual behavior:
A deleted file handle is left open each time the API endpoint is hit.

Environment info:

  • System info: Linux 5.4.0-148-generic x86_64
  • InfluxDB version: InfluxDB v2.6.1 (git: 9dcf880fe0) build_date: 2022-12-29T15:53:07Z

Config:
Default

cbainlive added a commit to cbainlive/influxdb that referenced this issue Sep 27, 2023
The returned function of errors2.Capture needs to be called to free the file descriptor.
cbainlive added a commit to cbainlive/influxdb that referenced this issue Sep 27, 2023
The returned function of errors2.Capture needs to be called to free the file descriptor.
cbainlive added a commit to cbainlive/influxdb that referenced this issue Sep 27, 2023
The returned function of errors2.Capture needs to be called.
cbainlive added a commit to cbainlive/influxdb that referenced this issue Sep 28, 2023
The returned function of errors2.Capture needs to be called.
cbainlive added a commit to cbainlive/influxdb that referenced this issue Sep 29, 2023
@cbainlive
Copy link
Author

In addition to the file descriptor leaking, there is disk space consumed by the OS as long as the process has it open.

I looked at the code and noticed that the issue is the File.Close method is not getting called correctly for this (and two other places) as implemented with a deferred call wrapping it with errors2.Capture. I have submitted a PR for it. Please consider adding this into the next 2.x build. Thanks.

@cbainlive
Copy link
Author

Hi, pinging on this ticket. I provided the fix and I'm hoping this can make it into the next 2.x build since I'm having trouble building myself from code--I am also hitting this issue: #24363.

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

No branches or pull requests

1 participant