@Override
    public void close() {
      if (!released) {
        releaseLocks();
      }
    }
The implementation here is a bit kludgey but done so that code exercised by unit tests
(which run against Derby which has no support for select for update) is as similar to
production code as possible.
In particular, with Derby we always run in a single process with a single metastore and
the absence of For Update is handled via a Semaphore.  The later would strictly speaking
make the SQL statements below unnecessary (for Derby), but then they would not be tested.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnStoreMutex.java