Add the ability to release the locks associated with reversed Txns#9045
Conversation
"Abandoning" a lock sounds more drastic than what we're actually doing, which is releasing the lock after any changes to the associated elements have been abandoned.
aruniverse
left a comment
There was a problem hiding this comment.
changes look fine to me, approving. do wonder if we should call this out in nextver.md
@khanaffan @rschili @simihartstein plz review
|
I built Studio against this branch and ran OS+ (unmodified) in it. And much to my surprise, OS+ undo/redo operations don't call into the code I modified at all! TIL about So I guess I will fix that. Looks like I will also need to add the new async functions here and to BriefcaseTxns so that they can be called from the frontend. |
|
This pull request is now in conflicts. Could you fix it @kring? 🙏 |
|
I've now tried this branch in OS+, and made some further changes based on that experience. A few notes:
const db = IModelDb.findByKey(key);
if (db.isBriefcaseDb()) {
return db.txns.reverseTxns(numOperations);
} else {
return db[_nativeDb].reverseTxns(numOperations);
}I don't think it makes any sense to call
Could be some room for improvement here, but it doesn't seem too bad.
|
|
@kabentley you have a couple of unresolved comments above, which I think are now the only thing stopping this PR from being auto-merged. Mind taking a look and seeing if you have any concerns? Thanks! |
Use |
|
Thanks @pmconne.
Looks like |
I spelunked into the rabbit hole and found that |
|
Ok thanks @pmconne, I've changed IpcHost.ts to use |
Fixes #8552 by making
ServerBasedLocksTxn-aware, so locks from reversed or canceled Txns can be safely abandoned and later reacquired for redo, without weakening existing lock guarantees.This PR:
ServerBasedLockslock cache, including upgrades of Shared -> Exclusive.TxnManagerfunctions for Txn reverse and cancel that automatically perform lock abandon, and functions for Txn reinstate that automatically perform lock reacquisition.TxnManagerfunctions intact and does not change their semantics, to preserve backward compatibility.reinstateTxnfails with LockNotHeld when required locks were previously abandoned, so lock semantics cannot be violated. This does not contradict the point above, and is not a breaking change, because clients using the synchronous reverse/cancel functions will not abandon the locks in the first place.Backward compatibility:
BackendHubAccessmethods are optional andServerBasedLocksknows how to use fallbacks when they're not available.LockControlis not available for external implementation, so new methods there do not represent breaking changes.Lock-correctness guarantees: