Fixes to LocalFile::lock()
* Added onTransactionResolution() DB method.
* Use this method so that file unlocks fire on unlockAndRollback()
as well as on DB errors (via MWExceptionHandler::handleException).
This prevents locks from getting stuck for minutes when deadlocks
happen, since the LockManager::destruct() method is not reliable.
* Fix broken reference counting which always released locks on the
first unlock() call, even if there were 2+ lock() calls.
* Added some type hints to IDatabase methods.
* Fixed DatabaseBase::__destruct() logging to include all callbacks.
Bug: T132921
Change-Id: I684706957f4d794cb6fe61505b0d26b7893de706