Concurrency exception on UPDATE (even with record locking)

I have two node.js processes running on separate servers that are doing UPDATES on the same class. The updates look like this (simplified here):

UPDATE test SET staged = true, tag = null RETURN AFTER @this WHERE (publish <= 100 AND staged = 99) LOCK RECORD


UPDATE test SET expires = 100, publish = 99 WHERE (@rid IN [...(list of RIDs)...]) LOCK RECORD

This works fine (and never generates an error with only one process running). But when both processes are running, I occasionally get: You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection: OrientDB.RequestError: Cannot UPDATE the record #12:1942 because the version is not the latest. Probably you are updating an old record or it has been modified by another user.

I thought that adding LOCK RECORD would prevent this? What is causing this concurrency error?

PS - This is ODB 2.2.29 and OJS 2.2.10.

@wolf4ood or @luigidellaquila - Can either of you shed some light on this? I’m trying to understand how these updates can produce a concurrency issue. To my understanding, the LOCK RECORD would cause all of the records matching the WHERE clause to be locked between the read and the write operation (i.e. the entire UPDATE is atomic). So even if two different processes executed the same statement at the same time, only one of them would find and update the matching records (note that there are generally no more than 10 or so that will match at any given time). But since I am regularly (although rarely) getting the concurrency error, it would seem that either my understanding is incorrect or that this is a bug in ODB 2.2.29.