If multi-threads call UDF function(with write-operation) on same record, there have internal locks or something else to protect the data?
Yes, records are locked during write operations (from either the client or from record UDF).
Locked when writing operation. How about reading?
Calling as_operations_add_incr(ops, “bin”, 1) from client should be thread-safe.
But calling a lua function below thread-safe ? :
if aerospike:exists(rec) then local v = rec['bin'] rec['bin'] = v + 1 return aerospike:update(rec) else ... end
More info here:
Thanks. The link is helpful
I am recently doing a POC on UDP with a similar use case. Can someone explain how aersopike avoids race condition when multiple threads call this UDP on same record?
Ahead of executing a record UDF on a specified key a record lock is obtained. If other threads are trying to do the same they will queue up.