Possible issues with expiration logic

Description

We can close out if Iā€™m wrong, but when I implemented the new getContextKeys SQL, I used a test for expiration based on the designated time being less than the expiration in the record, i.e. it considers the record expired if they match.

I think the queries going the other way may be off by 1 and treating equality as valid, so want to review.

Environment

None

Activity

Scott CantorAugust 23, 2023 at 12:28 PM

I believe so, when comparing things with the expiration time on the LHS.

expires <= now ā†’ expired

now < expires ā†’ valid

Rod WiddowsonAugust 23, 2023 at 10:52 AM

It seems like these are the problematic statements

"DELETE FROM StorageRecords WHERE expires < ? "; "DELETE FROM StorageRecords WHERE context = ? AND expires < ?"; "UPDATE StorageRecords SET expires=? WHERE context = ? AND expires > ?"; "SELECT id FROM StorageRecords WHERE context=? AND (expires IS NULL OR expires > ?)"; "SELECT id FROM StorageRecords WHERE context=? AND id like ? AND (expires IS NULL OR expires > ?)";

Iā€™m guessing that we need to systematically change expires < ? to expires <= ?

(it looks like <= is the correct syntax for less than or equal).

Fixed

Details

Fix versions

Assignee

Reporter

Created August 3, 2023 at 7:28 PM
Updated August 26, 2023 at 3:31 PM
Resolved August 23, 2023 at 12:54 PM

Flag notifications