Skip to content

Commit

Permalink
feat(engine): don't iterate over deleted keys
Browse files Browse the repository at this point in the history
When iterating in an open transaction, we would create an iterator containing all entries in the database as well as the entries in the transaction cache. This ensures any keys added in the same transaction are also encountered during iterating.

We do not do anything with the keys that are deleted within the transaction. As a result, when iterating we will go over keys that are already deleted. This is wrong. The keys are deleted, so we should not encounter them anymore during iterating.

(cherry picked from commit 84be02b)
  • Loading branch information
remcowesterhoud committed Oct 11, 2023
1 parent c6fef93 commit 31439f9
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public InMemoryDbIterator newIterator() {
final TreeMap<Bytes, Bytes> snapshot = new TreeMap<>();
snapshot.putAll(database);
snapshot.putAll(transactionCache);
deletedKeys.forEach(snapshot::remove);

return new InMemoryDbIterator(snapshot);
}
Expand Down

0 comments on commit 31439f9

Please sign in to comment.