Skip to content
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

Merged
merged 4 commits into from
Mar 1, 2021

Conversation

addisonj
Copy link
Contributor

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

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
Copy link
Member

@gmethvin gmethvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codelipenghui codelipenghui added this to the 2.8.0 milestone Feb 26, 2021
@codelipenghui codelipenghui added release/2.7.1 release/2.6.4 type/bug The PR fixed a bug or issue reported a bug labels Feb 26, 2021
@addisonj
Copy link
Contributor Author

cc @merlimat FYI

@jiazhai
Copy link
Member

jiazhai commented Feb 26, 2021

/pulsarbot run-failure-checks

assertNotEquals(dirtyCursor.getMarkDeletedPosition(), positions.get(positions.size() - 1));

// Give chance to the flush to be automatically triggered.
Thread.sleep(3000);
Copy link
Member

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.

Copy link
Contributor

@eolivelli eolivelli left a 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

@eolivelli
Copy link
Contributor

Please remove the Thread.sleep before merging this patch

@addisonj
Copy link
Contributor Author

@eolivelli @lhotari fix the test, as well as the test this was a variant of.

@codelipenghui
Copy link
Contributor

/pulsarbot run-failure-checks

1 similar comment
@addisonj
Copy link
Contributor Author

addisonj commented Mar 1, 2021

/pulsarbot run-failure-checks

@merlimat merlimat merged commit 34ca893 into apache:master Mar 1, 2021
addisonj added a commit to streamnative/pulsar-archived that referenced this pull request Mar 1, 2021
* 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
@codelipenghui codelipenghui deleted the mark_ind_delete_entry branch March 1, 2021 06:00
zymap pushed a commit that referenced this pull request Mar 1, 2021
* 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)
@zymap zymap added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Mar 1, 2021
zymap pushed a commit that referenced this pull request Mar 2, 2021
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.6.4 release/2.7.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants