Changed semantics of locking: instead of relying of locking running-db, an automatic lock bound to a session is maintained. When the session closes the lock is released.