Remove lock on environment at every transaction end

拜拜、爱过 提交于 2021-02-05 11:10:59

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!