Skip to content

Commit

Permalink
test(journal): verify concurrent deleteUntil and openReader
Browse files Browse the repository at this point in the history
The test is not deterministic because we cannot control the order of execution. However this tests have a higher chance of failing without the bug fix.

(cherry picked from commit a104fe3)
  • Loading branch information
deepthidevaki authored and github-actions[bot] committed Nov 29, 2021
1 parent 0ec264b commit 0854de1
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,35 @@ void shouldNotFailOnResetAndOpeningReaderConcurrently() throws InterruptedExcept
assertThat(latch.await(1, TimeUnit.SECONDS)).isTrue();
}

// Regression test for https://github.com/camunda-cloud/zeebe/issues/7962
@Test
void shouldNotFailOnDeleteAndOpeningReaderConcurrently() throws InterruptedException {
// given
final var latch = new CountDownLatch(2);
final var journal = openJournal(2);
for (int i = 0; i < 10; i++) {
journal.append(data);
}
final long indexToCompact = journal.append(data).index();

// when
new Thread(
() -> {
journal.deleteUntil(indexToCompact);
latch.countDown();
})
.start();
new Thread(
() -> {
journal.openReader();
latch.countDown();
})
.start();

// then
assertThat(latch.await(1, TimeUnit.SECONDS)).isTrue();
}

@Test
void shouldDeleteSegmentFileWhenReaderIsClosed() {
// given
Expand Down

0 comments on commit 0854de1

Please sign in to comment.