public RocksDB openDB(final DBOptions dboptions, final String path, final List<ColumnFamilyDescriptor> columnNames, List<ColumnFamilyHandle> familyHandles) throws RocksDBException { boolean printLockMessage = true; while (true) { try { return RocksDB.open(dboptions, path, columnNames, familyHandles); } catch (RocksDBException e) { if (e.getStatus().getCode() != Status.Code.IOError || !e.getStatus().getState().contains("While lock")) { throw e; } if (printLockMessage) { LOGGER.info("Lock file to RocksDB is currently hold by another process. Will wait until lock is freed."); System.out.println("Lock file to RocksDB is currently hold by another process. Will wait until lock is freed."); printLockMessage = false; } } // Add some wait until the next attempt try { TimeUnit.MILLISECONDS.sleep(ROCKSDB_OPEN_SLEEP_MILLIS); } catch (InterruptedException e) { throw new RocksDBException(new Status(Status.Code.TryAgain, Status.SubCode.None, "While open db")); } } }