How to use, view, and calulate "last update time"(lut) for the truncate command


#1

How to use, view and calculate last update time (lut) for the truncate command

Context

This article highlights the difference of using UNIX EPOCH time when issuing the truncate command and the use of CITRUSLEAF_EPOCH in the truncate log output.

Method

Truncate Command

To truncate or delete every record in a namespace or a given set whose “last update time”(lut) is older than the specified time the user will need to issue the following command on one node in a cluster.
The command is distributed to other nodes via SMD (System MetaData). Secondary index entries are also cleaned up as part of a truncate command as of version 3.12.1.

Here is an example to truncate a set prior to a specific time:

asinfo -v "truncate:namespace=test;set=testset;lut=1497953000000000000"
  • The lut in the truncate command must be specified in nanoseconds since the UNIX epoch(00:00:00 UTC on 1 Jan 1970).
  • You can use a converter website such as https://www.epochconverter.com, but will need to add trailing zeros for nanoseconds.
  • The lut can be given in hex (with a 0x prefix), decimal, or octal (with a 0 prefix).

Here is the Command Reference documentation on truncate: http://www.aerospike.com/docs/reference/info#truncate

Log Output

Upon successful execution of the truncate command a similar line of output will be written to the logs

Jun 21 2017 19:00:35 GMT: INFO (truncate): (truncate.c:199) {test|testset} got command to truncate to Jun 20 2017 10:03:20 GMT (235649000000)
  • The lut time displayed in the logs is in milliseconds since the Citrusleaf epoch (00:00:00 UTC on 1 Jan 2010).

The log time value is derived by calculating the truncate command time specified since the UNIX EPOCH minus the CITRUSLEAF_EPOCH time and then converting the difference to milliseconds.

TIME SPECIFIED SINCE UNIX EPOCH - CITRUSLEAF_EPOCH    = TIME OF TRUNCATION
1497953000000000000             - 1262304000000000000 = 235649000000000000

Then simply reduce the difference to milliseconds to get the time displayed in the logs:

nanoseconds(ns) :	235649000000000000
milliseconds(ms):	235649000000

Notes

What is CITRUSLEAF_EPOCH Time?

Aerospike compacts data by subtracting out the CITRUSLEAF_EPOCH time. The CITRUSLEAF_EPOCH is taken as the second before 12:00:01 am, January 1, 2010 GMT.

Time in the CITRUSLEAF_EPOCH in milliseconds(ms) can be calculated by the following formula.

UNIX EPOCH time(ms) - 1262304000000 = Time in CITRUSLEAF_EPOCH(ms)

Time in the CITRUSLEAF_EPOCH in nanoseconds(ns) can be calculated by the following formula.

UNIX EPOCH time(ns) - 1262304000000000000 = Time in CITRUSLEAF_EPOCH(ns)

Reference: http://www.aerospike.com/docs/guide/FAQ.html#definitions

Keywords

truncate UNIX EPOCH CITRUSLEAF_EPOCH

Timestamp

06/21/2017


How to get LUT of a record