influxdata / influxdata/influxdb

InfluxDB delete with predicate works for _measurement, but not for specific _field

Open
#20,399 30 comments 10 reactions 0 assignees View on GitHub
area/2.x kind/bug waiting/investigation
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

__Steps to reproduce:__
List the minimal actions needed to reproduce the behavior.

Here is the code I use (in python) to try and delete a specific `_field`:
```
def delete_data(data: str, org: str, bucket: str, token: str, db_url=INFLUX_URL) -> str:
url = f'{db_url}/api/v2/delete?org={org}&bucket={bucket}'
headers = {
'Authorization': f'Token {token}',
'Content-type': 'application/json'
}
response = requests.post(url, json=data, headers=headers)
response.raise_for_status()
return response

data = {
"start": "2020-12-01T00:00:00Z",
"stop": "2021-12-20T00:00:00Z",
"predicate": "_field=\"my_field\""
}
r = delete_data(data=data, org=ORG, bucket='my_bucket', token=MY_TOKEN)
```

I also tried with `curl` - same story:
```
curl --request POST "/api/v2/delete/?org=&bucket=" -H 'Authorization: Token ' -H 'Content-Type: application/json' --data '{
"start": "2020-12-01T00:00:00Z",
"stop": "2020-12-20T00:00:00Z",
"predicate": "_field=\"my_field\""
}'
```

This does not delete the `_field`.
The same code, works just fine with `_measurement`

__Expected behavior:__
I expect the data to be deleted.

__Actual behavior:__
Nothing.

__Environment info:__

* System info: Linux 4.15.0-128-generic x86_64
* InfluxDB version: I am running it through docker: quay.io/influxdb/influxdb:v2.0.3 (when I do influxd version it does not show the docker instance)
* Other relevant environment details: Container runtime is up 7 days.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the POST request to /api/v2/delete with the _field predicate, comparing it with the working _measurement predicate. Trace the delete API handling and verify that a regression test covers field-specific deletion across the reported date range; done means the matching field data is removed as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.