aerospike/spring-data-aerospike

when I use @Document expiration then throw AerospikeException(resultCode = 22)

boojongmin opened this issue · 4 comments

hello.

when I use this code

@Document(expiration = 30000)
data class Test(
    @Id
    val id: String,
    val test: Long,
): Serializable {
    companion object {
        private const val serialVersionUID = 1L
    }
}

then occurred exception where AsyncWrite
(reactive aerospike client)

image

but I remove @document expiration option then error is gone.

@Document(expiration = 30000)
data class Test(
    @Id
    val id: String,
    val test: Long,
) : Serializable {
    companion object {
        private const val serialVersionUID = 1L
    }
} 

when I add expiration on @document then I meet exception.

how I add ttl? and pass error?

Thank you.

ps - dependencies

    implementation("com.aerospike:spring-data-aerospike:2.4.2.RELEASE")
    implementation("com.aerospike:aerospike-client:5.0.6")

TTL is disabled by default,
The server configuration that is responsible for expiration/eviction called “nsup-period” (default is 0 which is disabled).

For more information:
https://docs.aerospike.com/docs/operations/configure/namespace/retention/index.html

You can change the nsup-period and default-ttl configurations in the aerospike.conf file to enable expiration.

For example:

namespace test {
        replication-factor 2
        memory-size 1G
        default-ttl 30d # 5 days, use 0 to never expire/evict.
        nsup-period 120
        #       storage-engine memory

        # To use file storage backing, comment out the line above and use the
        # following lines instead.

        storage-engine device {
                file /opt/aerospike/data/test.dat
                filesize 4G
                data-in-memory true # Store data in memory in addition to file.
        }
}

oh~ thank you.

I need ttls by set.

so I put config 'allow-ttl-without-nsup' to aerospike server

and use @Docuemnt(expiration=30)

thank you so much. :)

@boojongmin
According to https://docs.aerospike.com/docs/reference/configuration/index.html#allow-ttl-without-nsup
using 'allow-ttl-without-nsup' is not recommended, you should check out 'nsup-period' and 'default-ttl' configurations.

No problem :)

so I put config 'allow-ttl-without-nsup' to aerospike server

and use @Docuemnt(expiration=30)

This setup means that the record would not return to the client after they expire, but will never be purged from disk/memory. Set nsup-period to allow the namespace supervisor to expunge expired objects.