Behavior when using secondary indexes for reads

secondary
index

#1

Just wanted to understand the behavior when using secondary indexes for reads.

My Record looks like this:

Id | Bin1 | Bin2 | Bin3

There is a secondary index on Bin3(String)

Now when we do a read records that have Bin3 = “foo”.

What is the read behavior? Is a read request sent to all nodes in the cluster. What if some nodes are not responding?

Also how do we handle updates to this record. Is the response to the client blocked till all secondary indexes are updated successfully.


#2

Secondary index query request (read ) is sent to all the nodes in the cluster. Every node will send the result of the query to the client

If some nodes are nodes are not responding query will timeout. But you will get the results from other nodes.

Secondary indexes are updated synchronously with each write. The query will only be blocked when it is processing a record which is being written.


#3

When you say indexes are updated synchronously, could you please let me know what happens when updating the secondary index fails, but the record has been updated. AS does not support rollbacks.

So now the secondary index and primary index/records have diverged. Is this possible? Can i know somehow that this has happened, so that i can do a write repair.


#4

Aerospike does not roll back when secondary index fails. But we do save this information and show this sindex as not-synced when a user lists all the sindexes.

You can use aql command for this: aql> show indexes

However, this is a very unusual scenario.