[TransactionalLevelDB] Fix iterating 'Prev' from evicted iterators
Iterators in TransactionalLevelDB are evicted when there are any changes to the database. There is an edge case where an iterator is evicted while on the 'last' key of the database, and that key is deleted. When reloaded, it Seek()s to the previous key, only to become 'Invalid' because it reaches the end of the database. Unfortunately leveldb doesn't allow 'Prev' to be called from the end of the database and instead just stays invalid. The fix checks for the state where 'the iterator was valid before eviction and is invalid after reloading' in the Prev() method. In this state, there must be no no keys at or after the previously loaded key. Thus calling SeekToLast() will correctly position the iterator at the first element 'Prev' the previously loaded key. Bug: 1022594 Change-Id: Ifa938b441683ea9f2cac5d926ff22b734ab4bb67 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897007 Commit-Queue: Daniel Murphy <dmurph@chromium.org> Auto-Submit: Daniel Murphy <dmurph@chromium.org> Reviewed-by:Ken Rockot <rockot@google.com> Cr-Commit-Position: refs/heads/master@{#713947}
Showing
Please register or sign in to comment