-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix marking individual deletes as dirty #9732
Conversation
When we mark cursors as dirty, we aren't marking when individual acks cause a dirty cursor. This results in cursors not being flushed and causing redelivery. This one line fix will ensure we mark the cursor as dirty in this situation as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
cc @merlimat FYI |
/pulsarbot run-failure-checks |
assertNotEquals(dirtyCursor.getMarkDeletedPosition(), positions.get(positions.size() - 1)); | ||
|
||
// Give chance to the flush to be automatically triggered. | ||
Thread.sleep(3000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Thread.sleep
in test could lead to flaky tests. Is there a possibility to use Awaitility to poll for some condition or assertion? Similar logic with retrying using Awaitility:
Awaitility.await()
// Give chance to the flush to be automatically triggered.
.pollDelay(Duration.ofMillis(3000))
.untilAsserted(() -> {
// Abruptly re-open the managed ledger without graceful close
ManagedLedgerFactory factory2 = new ManagedLedgerFactoryImpl(bkc, bkc.getZkHandle());
try {
ManagedLedger ledger2 = factory2.open("testFlushCursorAfterInactivity", config);
ManagedCursor c2 = ledger2.openCursor("c");
assertEquals(c2.getMarkDeletedPosition(), positions.get(positions.size() - 1));
} finally {
factory2.shutdown();
}
});
By default, Awaitility will retry up to 10 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good.
Please use Awaitility, this is currently the way we do in order to have less flaky tests
I am +1 as soon as we improve the test
Please remove the Thread.sleep before merging this patch |
@eolivelli @lhotari fix the test, as well as the test this was a variant of. |
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
* Fix marking individual deletes as dirty When we mark cursors as dirty, we aren't marking when individual acks cause a dirty cursor. This results in cursors not being flushed and causing redelivery. This one line fix will ensure we mark the cursor as dirty in this situation as well * add a test * improve tests to not use sleep * make the polling rate be slower
* Fix marking individual deletes as dirty When we mark cursors as dirty, we aren't marking when individual acks cause a dirty cursor. This results in cursors not being flushed and causing redelivery. This one line fix will ensure we mark the cursor as dirty in this situation as well * add a test * improve tests to not use sleep * make the polling rate be slower (cherry picked from commit 34ca893)
* Fix marking individual deletes as dirty When we mark cursors as dirty, we aren't marking when individual acks cause a dirty cursor. This results in cursors not being flushed and causing redelivery. This one line fix will ensure we mark the cursor as dirty in this situation as well * add a test * improve tests to not use sleep * make the polling rate be slower (cherry picked from commit 34ca893)
When we mark cursors as dirty, we aren't marking when individual acks
cause a dirty cursor.
This results in cursors not being flushed and causing redelivery.
This one line fix will ensure we mark the cursor as dirty in this
situation as well