Error 100: function not found in aql after module was registered

I have just started trying out Aerospike and wanted to check out the UDF feature. I created a file called list.lua in the /usr/local/scripts directory and registered it on the aql prompt on the console. On registering the module, I got a ‘OK, 1 module added’ response.

However when I tried

execute list.push('mylist', 1) on foo.bar where PK = 'srini'

I got a ‘Error: (100) function not found’. I cannot figure out how to solve this problem. Is the file expected to be in a specific directory only??

I am currently using Aerospike Community Edition build 3.5.14 on Ubuntu 14.04

Also the contents of the list.lua file are as follows:

function push(rec, bin, value)
    local l = rec[bin]
    if (l == nil) then
        l = list()
    end
    list.prepend(l, value)
    rec[bin] = l
    local length = #l
    if aerospike:exists(rec) then
        aerospike:update(rec)
    else
        aerospike:create(rec)
    end
    return length
end

Please help if possible…

1 Like

Hi Srinivas. First step, how many nodes are in your cluster, and can you run the following from AQL:

show modules

This is what I get on show modules

+--------------------------------------------+------------+-------+
| hash                                       | module     | type  |
+--------------------------------------------+------------+-------+
| "3edde650a13b0672b1ffbec8e51de14cf55a9c49" | "list.lua" | "lua" |
+--------------------------------------------+------------+-------+

Also its not a cluster. Just a single node.

Okay, do you have logging enabled to track the UDF execution? There’s a good guide of how to do that in the Best Practices section of the UDF Developer Guide.

The log should give more information about what is going on. Right now I have two guesses, due to personal experience with similar problems:

  • If you have a multi-node cluster deployed on a single machine, you have to check each node’s var/udf/lua/ directory for the module. It should be the case that registering it copies the file to all nodes, but please confirm.
  • The server may not be able to find a copy of the module in a common path such as /opt/aerospike/usr/udf/lua/. The log should identify if this is the problem.
  • Try renaming the module to something other than list which can be a namespace collision.

Hi Ronen,

Thanks for the solutions. It is clearly the 3rd solution which I had a bit of a hunch on but wasn’t completely sure of. The minute I renamed the file to lists.lua and registered the module, it worked perfectly. However, I got this example from http://www.aerospike.com/docs/guide/record_udf.html and followed the instructions from there.

I guess the example there should be changed as the file name list.lua does create some kind of a collision. Also, it would be great if the system itself did not permit registering a module with a name that could conflict. In this particular case the module registered perfectly and made debugging the issue that much harder.

I really appreciate your help on this. Thanks again!!

Also, thanks for the tips on logging. I started Debug logs on UDFs and got this

Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_record.c:udf_storage_record_open:83) [ENTER] Opening record key:<Digest>:0x8b5f034e458e6e411f4c4112193cb8a9b02597cb
Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_record.c:udf_record_close:267) [ENTER] Closing record key:<Digest>:0x8b5f034e458e6e411f4c4112193cb8a9b02597cb
Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_free:449) [ENTER] NumUpdates(0)
Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_rw.c:send_result:526) FAILURE when calling list push function not found
Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_rw.c:send_udf_failure:414) Non-special LDT or General UDF Error(function not found)
Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_record.c:udf_record_close:267) [ENTER] Closing record key:<Digest>:0x8b5f034e458e6e411f4c4112193cb8a9b02597cb
Jul 07 2015 17:30:13 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_free:449) [ENTER] NumUpdates(0)

Not perfectly sure if the logs answer the problem, but its always good to have some logs :smile:

1 Like

I’m glad that helped. Thanks for pointing out that the documentation is lacking a warning about namespace collision. I’ll make a note to fix that!

I do not think its a namespace collision though. I do not have a namespace, set or a bin called list anywhere in the system.

It could probably be because list is a function in the aerospike UDF Lua API. I created a new function called map.lua and that also had the exact same error. So I guess those terms are reserved to be used within the udfs and not outside??

Yes, I meant ‘namespace’ in the programming sense, not our specific term for a container of sets. We need to document that you cannot name your modules the same as existing ones provided by the Aerospike Lua modules.