Search code examples
pythonaerospike

Delete record not working for aerospike persistent storage


I am using persistent storage for Aerospike. Below is the config for the same. I am using the python client for the same, when I remove the key using:

client.remove(key)

The data gets deleted. Now when I restart the server, the data is back. Is that how its supposed to work or am I doing something wrong?

Config file:

namespace xxx {
    replication-factor 2
    memory-size 2G
    default-ttl 60d # 5 days, use 0 to never expire/evict.


    # To use file storage backing, comment out the line above and use the
    # following lines instead.
    storage-engine device {
            file /opt/aerospike/data/xxx.dat
            filesize 4G
            data-in-memory true # Store data in memory in addition to file.
            write-block-size 128K
    }

}

Is there a work-around for the same?


Solution

  • I work at Aerospike and it's on the roadmap to address this behaviour.

    This is expected. When a delete happens the reference to the record is removed from the index but the record itself stays within the write block until that write block is rewritten with new data. When a cold start occurs, and data is read from the disk, blocks that have not been rewritten may have deleted records which are read and the system has no way to know that those records are deleted. So deleted data can come back.

    This is discussed in detail here:

    https://discuss.aerospike.com/t/expired-deleted-data-reappears-after-server-is-restarted/470

    Please note, this is only when Aerospike cold starts, in certain situations a warm restart is possible and deleted data will not reappear.