Skip to content

[pulsar-broker] schedule one add/read timeout task per ml/topic - #4111

Merged
merlimat merged 1 commit into
apache:masterfrom
rdhabalia:read_gc
Apr 24, 2019
Merged

merlimat merged 1 commit into
apache:masterfrom
rdhabalia:read_gc

Conversation

@rdhabalia

Copy link
Copy Markdown
Contributor

Motivation

It will schedule only one timeout task per ml/topic which times out stuck add/read request and fails the callback.

@rdhabalia rdhabalia added this to the 2.4.0 milestone Apr 23, 2019
@rdhabalia rdhabalia self-assigned this Apr 23, 2019
@rdhabalia

Copy link
Copy Markdown
Contributor Author

rerun java8 tests

@merlimat
merlimat merged commit 5e96a9c into apache:master Apr 24, 2019
// last read-operation's callback to check read-timeout on it.
private static final AtomicReferenceFieldUpdater<ManagedLedgerImpl, ReadEntryCallbackWrapper> LAST_READ_CALLBACK = AtomicReferenceFieldUpdater
.newUpdater(ManagedLedgerImpl.class, ReadEntryCallbackWrapper.class, "lastReadCallback");
private volatile ReadEntryCallbackWrapper lastReadCallback = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rdhabalia Just one comment here. If we're just doing get/set operations on the variable, then we don't need the updater object since LAST_READ_CALLBACK.set(this, someOtherVar) would be equivalent to doing lastReadCallback = someOtherVar (provided that lastReadCallback is already volatile).

We really need the updater if using compareAndSet() and similar ops.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's true..there is no use of AtomicReferenceFieldUpdater.. will fix it.

@dao-jun

dao-jun commented Apr 25, 2024

Copy link
Copy Markdown
Member

@rdhabalia Hi, I noticed we only introduced a single lastReadCallback field to store the ongoing read operations, does it mean we only check the last read operation is timeout or not?

For instance, there is a read operation A, we will set lastReadCallback to A, and check if it is timeout. But at the next second, there is another read operation B, lastReadCallback will set to B even A is not finished. So finally, we just check B is timeout or not, A is covered by B.

Is there something else I don't understand or a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants