'Expiration Seconds' error occurs when new retention time is >=99999 days?

I’ve set up a process in my application that allows me to send a request to a Golang InfluxDB client, such that a user can update a bucket’s retention time. The form to update the time takes in a number of days, converts that into seconds and then sends that number to the Golang client to update the requested bucket.

However, when I enter a number of days equal to, say, 99999, I will be returned an error from the client:
unprocessable entity: expiration seconds must be greater than or equal to one second

This does not seem to be a problem with magnitude because I can go to a higher amount of days - like 100000 - and the process will work as intended. However it seems to be that a large number of 9s in days causes this problem.

Has anyone else ran into this issue before?

Hello @jos,
I’m a little confused by

large number of 9s in days
are you creating buckets with retentions of seconds or days?
Finally, can you please share some of your go client code?
Thanks :slight_smile:

@Anaisdg

The code works like this:

The client prompt asks for a retention time in days:

image

The client then sends a message to the server with the bucket’s ID and the new retention time, converted from days into seconds by

daysToSeconds(days) {
    return Math.round(days * 24 * 60 * 60);
  }

The server takes this value of seconds and asks the golang influx package to update the bucket associated with that ID.

bucket, err := influx2Client.BucketsAPI().FindBucketByName(context.Background(), bucketID)
	if err != nil { 
		return err
	}

bucket.RetentionRules[0].EverySeconds = int(newRetentionTime)
_, err = influx2Client.BucketsAPI().UpdateBucket(context.Background(), bucket) // Error occurs here
	if err != nil {
		return err
	}

The error occurs when the bucket is updated. The exact error message is:
internal error: retention policy duration must be at least 1h0m0s

@jos it looks to me like you’re hitting an int overflow when some piece of the system converts seconds → time.Duration (nanoseconds), I’ll try to track it down. The end result will likely still be an error, but with a more-understandable message.

2 Likes
2 Likes

@dan-moran I should clarify that my retention value has been in days, not seconds (that is, the bug happens when I chose 99999 days, not 99999 seconds)