Drop all secondary indexes

Today we maxed out the number of secondary indexes and get the following error using the Java client: com.aerospike.client.AerospikeException: Error Code 206: Create index failed: FAIL:206:Reached maximum number of sindex allowed

show indexes reveals there is ~1080 indexes

I tried manually deleting them one by one and reduced them to 1020, but we still get the same error. I tried restarting Aerospike and also the web client, but no joy.

How do I fix the error? I take it the limit is 1023 secondary indexes?

Is there a way to drop all secondary indexes in one go?

Hi Rod,

Actually, the maximum number of secondary indexes per namespace is 256 (see here: Known Limitations | Aerospike Documentation). I’m not sure how you created over a 1000 - so that might be an unknown bug.

Why would you need 1000 secondary indexes in the first place? what is your use case and data model?

Zohar

Hi Zohar,

Thanks for the reply!

You’re right I think we must have hit the limit of 256 for one namespace. Since we have 6 namespaces, the 1000+ total must have been spread across the 6 of them.

We don’t need that many secondary indexes currently - it was the result of a penetration test performed on our system, and a bug in our code. So prior to the test we had around 360 secondary indexes, and I’d like to remove the unused secondary indexes. Do you know a way to drop them all?

As you pointed out our current data model is probably not scalable, so we are in the process of reviewing it after recently upgrading to Enterprise Edition.

Cheers, Rod

Hi Rod,

You can remove secondary indexes programmatically using the dropIndex function (Java) or index_remove (python).

A more destructive way could be to delete the sindex.smd file (/opt/aerospike/smd/sindex.smd) from all of the nodes. Once removed, you would need to fully restart the cluster (stop all nodes at the same time and start them back up). A rolling restart won’t work as the SMD (system metadata) would automatically propagate from the other nodes and restore the file.

I recommend not tweaking that file - I’m not sure how that would affect your system.

Also, welcome to the EE! :slight_smile: