Bitcoin full node and query server

Aug 5, 2020

View in context in the libbitcoin Slack #general mirror.

K
Kaichieh Ku01:08
Hi, I am trying to deploying v4 libbitcoin servers. I noticed that if I set flush_writes = true, the database will always corrupt with lock failure error. I also read the implementation of class flush_lock , and seems the failure is indeed can be triggered easily. Because flush_lock::try_lock only check the existence of the lock file without creating it, while flush_lock::lock_shared fails if it cannot create lock file immediately. Is this intentional? I think semantic behavior is try_lock for non-blocking lock (this is what flush_lock::lock_shared does currently), and lock_shared for blocking lock.
3 replies · evoskuil · last Aug 05, 2020
evoskuil05:24
Hi, v4 is not production code and deployment is definitely not recommended. I believe write flushing in v4 fails purposely because it is not actually supported yet due to changes to the store structure. The flush_lock semantics are as intended. lock_shared blocks on creation of the lock file. If creation fails there is an error, not simply a lock to wait on.
(edited)
🙏 1
evoskuil05:27
The flush lock exists only to cause a lock file to be left behind in the event of an uncontrolled shutdown. The lock is tested on startup, preventing execution in the case of a preceding uncontrolled shutdown.
(edited)
evoskuil05:40
The original simple startup/shutdown use of the lock is straightforward. However write flushing is essentially transactional commit. In v3 this could be guarded in each data file write independently. However v4 incorporates multi-file transactions, materially complicating write flushing. As you can see the lock attempts are not guarded, so the class is not thread safe across the shared lock file resource. In order to properly support transactional commit the class needs to accept a flush mutex and use it to apply an upgradeable lock around the lock file access. This will allow the flush lock to become an actual guard for transactional commit.
(edited)