When there are multiple requests to execute some code with a SOQL using For Update at same time, other Apex threads will wait the previous Lock released to execute the reminder code after the SOQL event though the previous thread SOQL does not return any records.
Is there a way to release all locks when a thread finds the lock is useless?
For example:
The SOQL:
Select Id from Account where Type = 'Customer' limit 1 For Update
Only 1 records in DB which matches the above SOQL. When 1K requests to execute this SOQL at same time, the first thread updates the Account.Type
to another value, can I release the reminder 999 locks at once?