what is the retention policy and how exactly it work?
as you know we can set retention policy “check-interval” on config file of influx.
what happen if i set this parameter and after that meet interval, which part of database remove?
what happen to the old data? i mean if i have database of 1 year ago retention will remove it ?
@Indeed_1 The database will only drop whole shards at a time. If you use the influx cli to run SHOW SHARDS you should see a listing of your database with their respective shards. Each of those shards has an expiry_time. Each check-interval the database will drop any of the shards who’s expiry times are older than time.Now().
@Indeed_1 That section is for shard-precreation. It will create empty shard files ahead of time. The section that deals with retentions (and the defaults) looks as follows:
This means the database will check every 30 minutes to see if the shard.expiry_time < now(). Also it will only drop shards if there is a duration > 0d. By the default retention policy that gets created with each database has infinite retention. You can check this with SHOW RETENTION POLICIES ON "mydb".
When I apply a new default retention policy to an existing DB I seem to lose access to any data already collected. SHOW SHARDS shows that a new shard with the new retention policy was created, but the old shard still exists. However, queries seem to be answered from the new shard which is empty. Is this the expected behaviour?
@Bill_Gunter You can query the old shard you just need to specify the retention policy. When querying use the fully qualified measurement name: "database"."retentionPolicy"."measurement". When querying without the fully qualified measurement name the db will return data from the DEFAULT retention policy, your empty new one. This is intended behavior.