Writing record with as_policy_write.AS_POLICY_KEY_SEND but at the time of key select keys are missing from record .it is multi node cluster

In multi node cluster setup , Aerospike AS_POLICY_KEY_SEND is giving intermittent show of keys. I am trying following things:

  1. Creating records with as_policy_write.AS_POLICY_KEY_SEND.
  2. Creating a secondary index on a string bin
  3. Using “as_query_where” and “aerospike_query_foreach” API on secondary index , I am getting all the records matching with the bin.
  4. retrieving key from record.
  5. removing record using “aerospike_key_remove”.

Expected result is removing all the records where bin is completely matching with a particular pattern.

My problem is when I did’nt get key , I am not able to remove that record . Though record is being created with suitable policy but still sometimes keys are not being recovered from server .

While doing same thing in single node aerospike instance , i do not see any problem in retrieving keys .

TIA

seems very familiar to other post… Lua record.key function returns nil you could accomplish this entire task using a udf. Not sure whats going on here, but could you just use the digest instead?

Correct. Queries only return user keys when found in the server records, but queries always return the key’s digest. The digest exists in the as_key struct and is sufficient to operate on the record. The following query callback example works even when the returned user key is null.

bool
query_cb(const as_val* p_val, void* udata)
{
	if (! p_val) {
		LOG("query callback returned null - query is complete");
		return false;
	}

	// The query didn't use a UDF, so the as_val object should be an as_record.
	as_record* p_rec = as_record_fromval(p_val);

	if (! p_rec) {
		LOG("query callback returned non-as_record object");
		return true;
	}

	// Remove each record found.  User key will be null, but digest is populated.
	as_error err;
	as_status status = aerospike_key_remove(&as, &err, NULL, &p_rec->key);
	LOG("remove status=%d", status)

	return true;
}