I'm trying to understand Salesforce's locking mechanism. I ran a test which does the following:
- Calls Database.setSavepoint().
- Issues a Select for Update query.
- Calls Database.rollback(savepoint).
- Delays for several seconds.
- Exits the transaction.
I expected other threads to be able to access the record once step 3 competed. What I see is that while the changes to the record are rolled back by step 3, other threads cannot access the record until after step 5. In other words, while the changes may be rolled back, the locks aren't released.
Is this understanding correct? Is there any way for the locks to be released by the rollback?