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

Delete statement ignores a retention policy #7053

Closed
alex-vv opened this issue Jul 24, 2016 · 6 comments
Closed

Delete statement ignores a retention policy #7053

alex-vv opened this issue Jul 24, 2016 · 6 comments

Comments

@alex-vv
Copy link

alex-vv commented Jul 24, 2016

Bug report

Delete statement ignores a specified retention policy and deletes data across all retention policies.

System info: InfluxDB 1.0 beta3, InfluxDB nightly (1.1.0~n201607220800) Ubuntu 14.04

Steps to reproduce:

# create database
curl http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

# create non-default retention policy myrp
curl http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY myrp ON mydb DURATION 365d REPLICATION 1"

# write data to default rp
curl -X POST "http://localhost:8086/write?db=mydb" --data-binary "cpu,region=useast,host=server_1,service=redis value=61"

# write data to myrp
curl -X POST "http://localhost:8086/write?db=mydb&rp=myrp" --data-binary "cpu,region=useast,host=server_1,service=redis value=62"

# delete data from myrp
curl "http://localhost:8086/query?db=mydb" --data-urlencode 'q=DELETE FROM myrp.cpu'
# alternatively tried
# curl "http://localhost:8086/query?db=mydb&rp=myrp" --data-urlencode 'q=DELETE FROM myrp.cpu'

# Query default rp
# Bug: expected it to return data, but no data comes back.
curl -G "http://localhost:8086/query?db=mydb" --data-urlencode 'q=SELECT * from cpu'

Expected behavior: Data deleted only from myrp retention policy

Actual behavior: Data deleted in all retention policies

@jsternberg jsternberg added this to the 1.1.0 milestone Aug 11, 2016
@jsternberg jsternberg self-assigned this Aug 11, 2016
@jsternberg
Copy link
Contributor

Looking at the docs, I think this is the intended behavior. @beckettsean thoughts?

http://docs.influxdata.com/influxdb/v0.13/query_language/database_management/#delete-series-with-delete

It seems to me like the behavior that he's saying seems more appropriate, but it would potentially be a breaking change.

@beckettsean
Copy link
Contributor

@jsternberg I agree the behavior is currently as intended, but also that it's not intuitive. Sometimes RPs are logically separate (all writes, all SELECT queries), and sometimes they aren't (SHOW and DELETE queries). I think we should pick one and get consistent, but that's a larger project than just this bug report.

@jsternberg jsternberg removed their assignment Oct 17, 2016
@jwilder
Copy link
Contributor

jwilder commented Oct 20, 2016

@we should either:

  1. Return an error if an RP is specified since since user would expect only data deleted from that RP, but we actually delete everything.
  2. Change the behavior to respect the RP.

I think 2 is preferable, but 1 might be an easier short term fix.

@joelegasse joelegasse self-assigned this Oct 20, 2016
@beckettsean
Copy link
Contributor

@jwilder I agree with implementing #1 for the 1.1 release.

Perhaps we can get a project for 1.2 where SHOW and DELETE queries treat RPs as logically separate, just like writes and SELECT queries?

@corylanou corylanou assigned corylanou and unassigned joelegasse Oct 20, 2016
@corylanou
Copy link
Contributor

@jwilder I need a final answer on the direction for resolving this issue. I can attempt 2, but if that involves a really big change, I can simply do 1 as an interim and punt 2 to a future milestone. Thoughts?

@jwilder
Copy link
Contributor

jwilder commented Oct 20, 2016

@corylanou See if you can get 2. If it's pretty involved, let's at least get 1 in.

@corylanou corylanou removed their assignment Oct 24, 2016
@jwilder jwilder self-assigned this Oct 25, 2016
jwilder added a commit that referenced this issue Oct 25, 2016
The delete and drop statements apply to the measurement within a db.
The parser allowed a db or rp to be specified and these values were
silently ignored.  This could cause data loss as someone would think
they are only deleting the series within a rp, but they are actually
deleting all their data.

Instead, we return a parse error if a db or rp is specified in the
delete or drop statements.  Ideally, we'd be able to respect the
db and rp, but that requires significant work in the query engine
and tsdb store to make that work.

Fixes #7053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants