HowTo completely delete namespace data without any cluster downtime


#1

HowTo completely delete namespace data without any cluster downtime

Context

A namespace data is to be completely deleted and re-used without bringing down the cluster.

Method

Aerospike Server version 3.12.1 or above

As of version 3.12.1, released in April 2017, set-delete is deprecated. Truncate the new feature of deleting all the data in a namespace or set is now supported in the database.

See the following truncate documentation: http://www.aerospike.com/docs/reference/info#truncate

Truncate can also be executed from the client APIs. Here is the java documentation: http://www.aerospike.com/apidocs/java/com/aerospike/client/AerospikeClient.html

In the Aerospike Enterprise Edition Server, truncation is preserved through a cold-restart.

In the Aerospike Community Edition Server, similar to record deletes, records in previously truncated sets can return through a cold-start.

Aerospike Server version 3.12.0 or below

The following steps are to be followed:

  1. Stop all client writes to the namespace.

  2. Issue a set-delete command for each set in the namespace. You can issue the command from asadm which will be administered on all the nodes in the cluster.

    In the following example, the set ‘testset’ in namespace ‘ns1’ is to be deleted:

     $ asadm
     Aerospike Interactive Shell, version 0.1.6
     Found 1 nodes
     Online:  192.168.1.1:3000
    
     Admin> asinfo -v "set-config:context=namespace;id=ns1;set=testset;set-delete=true;"
     192.168.1.1:3000 (192.168.1.1) returned:
     ok
    

    Source: http://www.aerospike.com/docs/operations/manage/sets#deleting-a-set-in-a-namespace

  3. Verify that all the data in the namespace has been removed. For example, querying statistics for namespace ‘ns1’ should return “objects=0” in the output for all the nodes:

     $ asinfo -v 'namespace/ns1' -l | grep '^objects='
     objects=0
    

    If you have data in a namespace that is not part of a set, you will need to traverse the namespace, and delete each and every record, or you can write a User Defined Function (UDF) for the same.

    Source: http://www.aerospike.com/docs/reference/info#sets

  4. For each node in the cluster:

    i. Stop the ASD on the node.

    $ sudo service aerospike stop
    Stopping aerospike:                                        [  OK  ]
    

    ii. Zero the data on the partitions using the ‘dd’ command:

    # dd if=/dev/zero of=/dev/[device] bs=1M
    

    The set-delete command will remove the data from the index. With a replication factor of two, it is also important for other nodes in the cluster to know that this data does not exist anymore. The "dd" command is issued to prevent any old data from returning on a cold restart.

    iii. Start the ASD on the node.

     $ sudo service aerospike start
     Starting and checking aerospike:                           [  OK  ]
    

    Depending on the type of write workload, it may be preferable to wait for migrations to complete between each node. Refer: How can I tell when a migration is finished?

    As a final step, you can once again verify that there are no objects in the namespace after the ASD has started.

Keywords

DELETE DATA NAMESPACE

Timestamp

9 February 2017