Another UDF Error 100 debugging

I have read other threads regarding the missing (or not registered) UDF modules, but the solutions doesn’t seem to work in my case. I have registered a module recombee.lua (using aql), and I can successfully list it and get it using following Python 3 script:

import aerospike

config = {
    'hosts': hosts,
    'lua': {'user_path': '/opt/aerospike/usr/udf/lua/'}
}


client = aerospike.client(config).connect()

print(client.udf_list())
print(client.udf_get('recombee.lua', aerospike.UDF_TYPE_LUA))

But when I try to apply it:

query = client.query('rcm', 'purchases')
query.apply('recombee', 'interactions_count_by_item_id', ['item-5315'])
res = query.results()

, it fails with

exception.UDFError: (100, 'UDF: Execution Error 1', 'src/main/aerospike/aerospike_query.c', 907)

I turned logging of UDF on according to http://www.aerospike.com/docs/udf/best_practices.html#logging, but I don’t see any errors. On 2 of 3 nodes is output like:

Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:225) [ENTER] Opening record key:<Digest>:0xddb3a2e037037f91c6bfa77cdbf757eb1b85c424
Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:84) [ENTER] Opening record key:<Digest>:0xddb3a2e037037f91c6bfa77cdbf757eb1b85c424
Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:712) [ENTER] rec(0x7fec952180e0) name(itemId)
Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:445) [ENTER] BinName(itemId) 
Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:496) [ENTER] urecord(0x7fecbd5dd050) name(0x41e48930)[itemId] dirty(0)
Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:286) [ENTER] Closing record key:<Digest>:0xddb3a2e037037f91c6bfa77cdbf757eb1b85c424
Jan 18 2017 18:38:03 GMT: DEBUG (udf): (udf_record.c:462) [ENTER] NumUpdates(1) 

and the third one doesn’t print anything.

Any help appreciated :slight_smile:

Check if you client has write privilege to the directory specified in user_path.

If not do: sudo chown <client_userid> /opt/aerospike/usr/udf/lua

and try.

Otherwise, share your record format (bins etc) and udf code to see what may be going on.

We managed to solve it by calling

client.udf_put('recombee.lua')

I don’t know why it helped as the module was previously registered using aql, and Aerospike knew where to find it (because it returned it in the listing (client.udf_list() in Python script) and it was also listed in aql > show modules ). Maybe some sort of problems with cache (didn’t have disabled cache)?

@pgupta Thanks for your suggestion :wink:

aql puts the udf on the server node. stream udfs run both on server node and client node. when you use udf_put() you will also put it on the client node if you used user_path in the config - which you did, and have write permission on client node’s user_path. When you do udf_get() you are getting the server copy. stream udf will first run reduce() on server node(s), then final reduce() is completed on the client node.

2 Likes

I didn’t realize that the code must be on both server and client nodes because of the final reduce() , but now I understand where was the problem. Thanks for explanation!

happy aerospiking ! :slight_smile: