Creating new bin for new record gives Invalid Operation

I am using a udf which creates a new record with a bin. This is the function:

function insertSegmentBuilder(rec, uid, segment)

   if not aerospike:exists(rec) then

      rec['uid'] = uid
      local segmentsList = list()
      list.append(segmentsList, segment)
      rec['segments'] = segmentList
      aerospike:create(rec)

   end

end

I am seeing some warnings in the log which says:

May 19 2015 20:08:51 GMT: WARNING (udf): (udf_aerospike.c::117) udf_aerospike_delbin: Invalid Operation [Bin name(segments) not found of delete]... Fail

I am not sure how adding a bin for a user would call the udf_aerospike_delbin? Do you guys know what could cause this issue?

Thanks, Phu

Phufool,

You are creating list segmentsList and but trying to assign segmentList (Check the variable name there is missing s). Lua considers this unknown variable as nil. So your statement actually means you are trying to assign nil value to a bin ‘segments’ which translates to attempt to delete a bin. Which fails …

you may want to run

luac -p -l <lua file name> | grep ETGLOBAL | grep -v "trace\|debug\|warn\|tostring\|map\|list\|aerospike\|info\|record\|error\|require\|bytes\|type\|getmetatable\|math\|pairs\|string"

on lua code to check if there are some undefined globals. Above code greps out some commonly occuring reserved words.

– R