Skip to content

Commit

Permalink
merge: #933
Browse files Browse the repository at this point in the history
933: Backport 876 to stable/8.2 r=nicpuppa a=remcowesterhoud

#876 

Co-authored-by: Remco Westerhoud <[email protected]>
  • Loading branch information
zeebe-bors-camunda[bot] and remcowesterhoud authored Oct 11, 2023
2 parents d1dc633 + 31439f9 commit 9e73b1b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package io.camunda.zeebe.process.test.engine.db;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

import io.camunda.zeebe.db.ColumnFamily;
import io.camunda.zeebe.db.TransactionContext;
Expand Down Expand Up @@ -492,6 +493,25 @@ void shouldWriteKeyAfterDeletion() {
assertThat(oneColumnFamily.get(oneKey).getValue()).isEqualTo(-2);
}

@Test
void shouldNotIterateOverDeletionsInTransaction() throws Exception {
// given
oneKey.wrapLong(1);
oneValue.wrapLong(-1L);
oneColumnFamily.insert(oneKey, oneValue);
transactionContext.getCurrentTransaction().commit();

// when - then
transactionContext.runInTransaction(
() -> {
oneColumnFamily.deleteExisting(oneKey);
oneColumnFamily.forEach(
(key, value) -> {
fail("Should not iterate over deleted keys");
});
});
}

private enum ColumnFamilies {
DEFAULT, // rocksDB needs a default column family
ONE,
Expand Down

0 comments on commit 9e73b1b

Please sign in to comment.