The feature on Custom Records 'ENABLE OPTIMISTIC LOCKING' when ticked, is actually expected to throw the error:
“Unable to save record. Record was changed by a different user. Please reload and try again.”
As similarly described in SuiteAnswers 24215, enabling this option causes the system to check for conflicting updates whenever a user or script attempts to save updates to an instance of this custom record type. If another user or script has saved updates to the same custom record instance during the time that the first user or script was entering updates, the following message is returned:
"Unable to save record. Record was changed by a different user. Please reload and try again."