Bulk Durable Delete

We’re using the official Node.js Aerospike client and would like to make use of a bulk durable delete.

A non-persistent delete is doable via the following background UDF.

function delete(rec)
	aerospike:remove(rec)
end

A call to those UDFs is done via a background job like e.g.

const client = await Aerospike.connect()
const query = client.query(namespace, set, { nobins: true, filters: [filter] })
const job = await query.background(backgroundJob, 'delete')
await job.wait()

In case it’s done per-record and not via a stream, the functionality would look like the following one.

const client = await Aerospike.connect()
const query = client.query(namespace, set, { nobins: true, filters: [filter] })
const stream = query.foreach()

await new Promise((resolve, reject) => {
	stream.on('error', (error) => reject(error))
	stream.on('end', resolve)
	stream.on('data', ({ key }) => client.remove(key))
})

For a durable delete (Enterprise Feature), the only for us working implementation is the following one.

const client = await Aerospike.connect()
const query = client.query(namespace, set, { nobins: true, filters: [filter] })
const stream = query.foreach()

const policy = new policy.RemovePolicy({
	durableDelete: true
})

await new Promise((resolve, reject) => {
	stream.on('error', (error) => reject(error))
	stream.on('end', resolve)
	stream.on('data', ({ key }) => client.remove(key, policy))
})

As the provided solution for a durable delete is a per-record solution, the question is now how to implement a bulk durable delete with a background UDF or if not possible via a stream-based solution?

© 2021 Copyright Aerospike, Inc. | All rights reserved. Creators of the Aerospike Database.