原始文献 / 论坛帖 / Re: RFC: remove DB_PRIVATE flag

Re: RFC: remove DB_PRIVATE flag

Bitcointalk · 2010-08-26 00:33:28 UTC

AuthorSatoshi Nakamoto
TitleRe: RFC: remove DB_PRIVATE flag
Date2010-08-26 00:33:28 UTC
ForumBitcointalk · 原文

能详细说说去掉 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.