influxdata / influxdata/influxdb

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

Open
#24,366 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the leak against GET /api/v2/backup/metadata and checking the deleted-handle count with lsof as described. Trace the endpoint's request handling and resource lifecycle. Done means repeated requests no longer leave additional deleted file handles open, with the behavior verified on the stated Linux and InfluxDB versions.

Written by the indexing model from the issue text.

Assessment

Domain
api, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.