回复:RFC:移除 DB_PRIVATE 标志
原始发布页
打开来源页面查看 1 个交叉存档
你能否更详细地说明移除 DB_PRIVATE 会产生什么影响?
我记不清自己当初使用 DB_PRIVATE 是否有某个具体理由,还是只是从某段示例代码中复制了这些标志。移除 DB_PRIVATE 后,其他进程同时打开数据库是否会变得安全?这可能是一项改进,具体取决于它有什么副作用。它是否会因为必须立即写出每一项更改或进行其他协调而大幅降低性能?那样会不会增加锁文件或协调文件?还有什么会发生变化?你可以分别在使用和不使用 DB_PRIVATE 的情况下,为首次下载区块计时来测试,最好用 -connect 连接到本地机器,这样网络就不会成为影响因素。
显然,DB_PRIVATE 并不会做到人们原本希望它做的事,也就是阻止其他进程打开数据库。它仍然允许其他进程打开,只是它们这样做时会把事情搞砸。另一个选择是,如果有办法的话,让它锁定数据库文件,使其他进程无法访问这些文件。
英文原文
展开英文原文
Can you provide more details about what removing DB_PRIVATE does?
I can't remember if I had a specific reason for DB_PRIVATE, or if I just copied the flags from some example code. Does removing DB_PRIVATE make it safe for other processes to open the database simultaneously? That may be an improvement, depending what the side effects are. Does it substantially reduce performance by making it have to write out every change immediately or do other coordination? Are there additional locking or coordination files then? What else changes? You could test by timing an initial block download with and without DB_PRIVATE, preferably -connect-ing to a local machine so network isn't a factor.
Apparently, DB_PRIVATE doesn't do what you would hope it would do, which is prevent other processes from being able to open the database. It still lets them, it just screws up if they do. Another option, if there's a way, would be to make it lock the database files so they can't be accessed by other processes.