Help debugging Error: code: 100, message: 'UDF: Execution Error 1


#1

Can’t figure out what’s happening here and log file isn’t indicating anything useful.

Error:

scanAggregate Error:  { code: 100,   message: 'UDF: Execution Error 1',   func: 'aerospike_query_foreach',   file: 'src/main/aerospike/aerospike_query.c',   line: 808 }

On my end using node.js as client. UDF file is:

local function starts_with(map,rec)
    if tostring(rec.tweet):find('%a+') ~= nil then
        map['tweets'] = map['tweets'] .. ',' .. tostring(rec.tweet)
    end
  return map
end

local function reduce_stats(a,b)
    a.tweets = a.tweets .. b.tweets
    return a
end

function find(stream,chars)
  return stream : aggregate(map{tweets='',chars=chars},starts_with) : reduce(reduce_stats)
end

Node.js code:

var statement = {aggregationUDF: {module: 'findtweet', funcname: 'find', args: ['please']}};
var query = client.query('test', 'tweets', statement);
var stream = query.execute();
stream.on('data', function(result)  {
    var tweets = result.tweets.split(",").filter(function(e){return e});
    console.log('Tweets: ', tweets);
    console.log('Count: ', tweets.length);
});
stream.on('error', function(err)  {
    console.log('scanAggregate Error: ',err);
});

And udf.log file contains many lines of the same thing which look like this:

Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_free:448) [ENTER] NumUpdates(1) 
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_open:205) [ENTER] Opening record key:<Digest>:0xfd8fe98439939a0ecb4933f7994f69b84a9f20c0
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_storage_record_open:83) [ENTER] Opening record key:<Digest>:0xfd8fe98439939a0ecb4933f7994f69b84a9f20c0
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_get:687) [ENTER] rec(0x7f75acbb7280) name(tweet)
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_get:424) [ENTER] BinName(tweet) 
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_set:481) [ENTER] urecord(0x7f75acbb7940) name(0x40f61938)[tweet] dirty(0)
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_get:687) [ENTER] rec(0x7f75acbb7280) name(tweet)
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_get:424) [ENTER] BinName(tweet) 
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_close:266) [ENTER] Closing record key:<Digest>:0xfd8fe98439939a0ecb4933f7994f69b84a9f20c0
Jun 11 2015 06:25:56 GMT: DEBUG (udf): (udf_record.c:udf_record_cache_free:448) [ENTER] NumUpdates(1) 

Any ideas on whats going on here? I’ve simplified UDF file to just find any tweets that matches any word. Doesn’t matter what I search the end result is that error.

Have tried playing with the example provided here

I am using test data from the online course.


How to sort all records in a SET based on one BIN in Aerospike
#2

Hi Denisbetsi,

The UDF file must be available in the modlua-userPath location. This path can be set through the config while creating client object. This is query_aggregate example which sets the path as follows. modlua:{userPath: /path/to/lua/file} https://github.com/aerospike/aerospike-client-nodejs/blob/master/examples/query_aggregate.js

More details:

The map-reduce functions in the aggregation query runs the map-reduce functions inside each node in the cluster and returns the resultset to client. The client runs the final reduce job on the all those data returned. To run the final reduce on client, the client needs to be aware of the UDF/LUA file and that is specified using modlua:userPath in configuration object. This is the doc describing configuration object. https://github.com/aerospike/aerospike-client-nodejs/blob/master/docs/configuration.md

Thanks


#3

I loaded LUA files through the AMC. So if I have multiple projects using different UDF functions, in order to share the functions copy of each file must be inherited by each project?


How to sort all records in a SET based on one BIN in Aerospike
#4

Yes. Copy of the file, containing the function you would like to execute must be available in modlua user path for that project. However you can have a common modlua userpath for all the projects and have all the UDF files in the path specified.

Thanks


#5

Right for as long as projects operate from same file system. Otherwise there must be some sort of a central library that all projects inherit in case of a distributed processing network with multiple projects and developers.