Records with ttl set never have their expiration time shortened

I saw the following sentence on the cold start page. “Records with ttl set never have their expiration time shortened.”, What does that mean, please?

I believe the sentence appears on this page that describes the behavior during a cold restart. It simply means the record’s ttl was never modified to a smaller value. The significance of a record’s ttl ever being shortened is that there is a possibility of the older, longer ttl version on the disk, reappearing although it has been superseded by a shorter ttl version if that version expired but was not written to disk. If a record’s ttl was never shortened, an older version will not be resurrected during cold restart.

For a more detailed discussion, you can read this article.

Thank for your excellent answer. Does this mean that if I use TTL to create a record, but then update it with a smaller TTL:

  • Record created with ttl1 (gen-1 / ttl1 - void time t1)

  • Record updated with ttl2 (gen-2 / ttl2 - void time t2 < t1)

  • Record expires

    public static void main(String[] args) {
        // save to aerospike , set ttl to 30s
        saveWithExpiration(30);

        // update record ttl, set ttl to 1s
        saveWithExpiration(1);
    }

    private static void saveWithExpiration(int expire) {
        WritePolicy writePolicy = new WritePolicy();
        writePolicy.expiration = expire;
        Key key = new Key(NAMESPACE, SET_NAME, KEY_NAME);
        Bin bin = new Bin(BIN_NAME, "expire time " + expire);
        aerospikeClient.put(writePolicy, key, bin);
    }

The records with Gen-2 may not be written to disk due to the reason that the defragmentation is overwritten, so I will bring back the records with gen-1 when I cold start aerospike.

The example is correct. Note you may only change the expiration time without bin updates using “touch” operation. A general statement is that if a record’s ttl is ever shortened (set to an earlier expiration time), an older version with farther out expiration may be resurrected during cold restart.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.