问题
Since it possible for one JVM process to write to Xodus and other JVM to read to the same environment, what is the correct way for a JVM process or method to remove the lock of the environment at end of every transaction as such other JVM processes would be able to write to the same environment at their own respective transactions?
回答1:
The xd.lck
file is never being removed, it is being locked by an Environment which is allowed to write. For implementation details, look at LockingManager.
If one Environment is in write mode, it is possbile to open another one (and several such) in read-only listening mode against the same physical database:
final EnvironmentConfig config = new EnvironmentConfig().
setLogDataReaderWriterProvider("jetbrains.exodus.io.WatchingFileDataReaderWriterProvider");
final Environment env = Environments.newInstance(dir, config);
This way to open Environment can be used in the same or another JVM.
来源:https://stackoverflow.com/questions/62012463/remove-lock-on-environment-at-every-transaction-end