Skip to content

Reduce use of timed locks, replace interprocess locks with regular locks

Bartek Wrona requested to merge locking-rework into develop

Fixed longstanding lock bugs:

  1. Timed locks (locks that can timeout) can fail to get lock for no reason (although very rarely), so any code using them needs to account for this. All read locks by default previously used timed locks. Now read locks are untimed by default (code blocks until lock is acquired). Both write_queue and p2p threads only use untimed locks now. For the most part, API calls still use timed locks, although we allow the code to get an untimed lock to the forkdb if it already holds a read lock on chainbase, because an unchanging chainbase implies that forkdb will not be changed. Heavy API load testing should be performed to ensure that they get no untimed locks that could degrade performance of the write_queue thread.
  2. Fixed a race in diagnostic variables _write_lock_count and _read_lock_count by making them atomic.
  • Improved debugging code for identifying lock-related problems, added new DEFINE to enable it: DEBUG_FORKDB_LOCK_TIMES
  • switched from using boost::interprocess locks to using regular boost locks as there's no interprocess use of these locks.
Edited by Dan Notestein

Merge request reports