[2.2] Resolve two race conditions relating to HA lock sessions

- Add a check ensuring a slave commit has a running lock session when committing,
  or has explicitly opted out from having one.
- Move lock session management into its own class, where timeouts and concurrent
  access can be tested in isolation.
IMO it is better to throw some checked exception here and in `TimedRepository#acquire(KEY)` as we really want caller to catch those. It is also possible to return some values indicating failure and not throw exceptions to avoid `fillInStackTrace` calls, thought this should not be a hot path