Set iterator read bounds on deleting column families to avoid very slow syncs #7664
Labels
A-state
Area: State / database changes
C-bug
Category: This is a bug
C-security
Category: Security issues
C-tech-debt
Category: Code maintainability issues
I-remote-trigger
Remote nodes can make Zebra do something bad
I-slow
Problems with performance or responsiveness
Motivation
Iterating on a column family that deletes lots of keys can be very slow.
We fixed some of this code in PRs #7663 and #7392, but we need a general fix to stop this issue happening again.
This currently impacts the
utxo_loc_by_transparent_addr_loc
column family, and any future uses of iterators withzs_delete()
. It can be remotely triggered.Specifications
The RocksDB documentation recommends specifying lower and upper bounds on iterators:
https://github.com/facebook/rocksdb/wiki/Iterator#iterating-upper-bound-and-lower-bound
https://docs.rs/rocksdb/latest/rocksdb/struct.ReadOptions.html#method.set_iterate_range
https://docs.rs/rocksdb/latest/rocksdb/struct.DBCommon.html#method.iterator_cf_opt
This is how these bugs in other projects...
https://tracker.ceph.com/issues/55324
https://jira.mariadb.org/browse/MDEV-19670
Were fixed in those projects:
https://github.com/ceph/ceph/pull/46096/files
facebook/rocksdb#5403
Complex Code or Requirements
We need to use iterators for some operations, so our alternatives are (in preferred order):
If this solution passes our benchmark tests, we should document it in:
https://github.com/ZcashFoundation/zebra/blob/main/book/src/dev/state-db-upgrades.md
Testing
When we implement the test in ticket #7649, it will also cover this change.
Documentation
We should document this issue in the developer state upgrade docs.
Related Work
This is a long-term fix for #7618.
PR #7663 implements alternative 2 for some column families.
PR #7392 implements alternative 1 for some column families.
The text was updated successfully, but these errors were encountered: