Extract confirmation height to its own database #2174
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While logically connected to an
account_info
the confirmation height is updated separately in a different thread. This means a lock is required when using something like RocksDB because there can be write conflicts when writing to the same account. Asaccount_put
is only called as part of theblock_processor
thread and confirmation height for existing accounts is done in the confirmation height processor thread (and new accounts in the block processor thread) no external synchronization should be required if they are separated. This won't help with lmdb yet because it uses a single global write lock, it would require it to be moved to a completely separate store file. This wasn't done (as moving it to a new database was painful enough), but this would help with other backends which don't use a global write lock (e.g rocksdb) and also enable it to be moved to a new lmdb store more easily if required.It's very important to keep the accounts in
accounts_v0/_v1
in sync with theconfirmation_height
database. There is a debug assert inaccount_put
which has a precondition that the account exists in theconfirmation_height
database. No such check exists inaccount_del
because it may just be removing fromaccounts_v0
to put inaccounts_v1
and so makes sense to keep theconfirmation_height
entry and not impose a precondition there.