I wanted to know if callback function given for aerospike_query_async needs to be thread safe? It’s explicitly mentioned in C client API docs that aerospike_query_foreach callback should be thread safe. No such information is available when it comes to aerospike_query_async.
No. The reason is the sub-query commands to each node are all placed on the same event loop thread. Therefore, the aerospike_query_async callback does not need to worry about thread safety.
The aerospike_query_foreach callback does need to be thread safe because the sub-query commands to each node are run in parallel threads from the synchronous thread pool.