`rec[bin] = nil` does not work when info() called on rec[bin] afterwards

udf

#1

I have a function that clears a specified bin:

local function clear(rec, id)
    rec[MAP_BIN_PREFIX .. tostring(id)] = nil
    info('data: ' .. tostring(rec[MAP_BIN_PREFIX .. tostring(id)]))
    aerospike:update(rec)
end

When an info statement printing the bin data occurs after bin erasure but before the record is updated (i.e. as shown above), two anomalies happen:

  • (1) the info() statement prints the original bin state (not the nil state)
  • (2) no changes are persisted to database

Simply removing the info() line fixes this issue.

This looks like a bug to me. It stumped me for a good while, especially because I was using info statements to debug the problem, but I think the above description is accurate now.

Perhaps the Aerospike Team could take a look or give some tips about this behaviour?


#2

Thanks for this – it is indeed a bug in the handling of nulled-out bins. After a bin is cleared, any subsequent reference to its value (i.e. a bin read) before the record is updated will restore the previous value.

We’ve fixed this and the fix will be in an upcoming release, likely towards the end of this month (March). Thanks again.


#3

You’re welcome! Thank you too for the update.


#4

Server version 3.7.4.1, recently released, contains the fix.