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

[pulsar-client] Fix multi topic reader has message available behavior #13332

Conversation

Demogorgon314
Copy link
Member

@Demogorgon314 Demogorgon314 commented Dec 15, 2021

Motivation

When we use a multi-topic reader, the hasMessageAvailable method might have the wrong behavior, since the multi-topics consumer receives all messages from the single-topic consumer, the single-topic consumer hasMessageAvailable might always be false (The lastDequeuedMessageId reach to the end of the queue, all message enqueue to multi-topic consumer's incomingMessages queue).

We should check the multi-topics consumer incomingMessages size > 0 when calling hasMessageAvailable .

Modifications

  1. Add a check of incomingMessages size > 0
  2. Add units test testHasMessageAvailableAsync to verify the behavior.

Documentation

Need to update docs?

  • no-need-doc

This is a bug fix.

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 15, 2021
@Demogorgon314 Demogorgon314 force-pushed the fix/multi-topic-reader-has-message-available-behavior branch from 36c3e71 to d09e0b3 Compare December 15, 2021 13:27
@Demogorgon314
Copy link
Member Author

/pulsarbot run-failure-checks

@Demogorgon314
Copy link
Member Author

/pulsarbot run-failure-checks

1 similar comment
@Demogorgon314
Copy link
Member Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit 6c7dcc0 into apache:master Dec 23, 2021
@Demogorgon314 Demogorgon314 deleted the fix/multi-topic-reader-has-message-available-behavior branch December 23, 2021 09:53
zymap pushed a commit that referenced this pull request Dec 23, 2021
…#13332)

### Motivation

When we use a multi-topic reader, the `hasMessageAvailable` method might have the wrong behavior, since the multi-topics consumer receives all messages from the single-topic consumer, the single-topic consumer `hasMessageAvailable` might always be `false` (The lastDequeuedMessageId reach to the end of the queue, all message enqueue to multi-topic consumer's `incomingMessages` queue).

We should check the multi-topics consumer  `incomingMessages` size > 0 when calling `hasMessageAvailable `.

### Modifications

1. Add a check of `incomingMessages` size > 0
2. Add units test `testHasMessageAvailableAsync` to verify the behavior.

(cherry picked from commit 6c7dcc0)
@zymap zymap added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Dec 23, 2021
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Dec 29, 2021
…apache#13332)

### Motivation

When we use a multi-topic reader, the `hasMessageAvailable` method might have the wrong behavior, since the multi-topics consumer receives all messages from the single-topic consumer, the single-topic consumer `hasMessageAvailable` might always be `false` (The lastDequeuedMessageId reach to the end of the queue, all message enqueue to multi-topic consumer's `incomingMessages` queue). 

We should check the multi-topics consumer  `incomingMessages` size > 0 when calling `hasMessageAvailable `.

### Modifications

1. Add a check of `incomingMessages` size > 0 
2. Add units test `testHasMessageAvailableAsync` to verify the behavior.
codelipenghui pushed a commit that referenced this pull request Dec 30, 2021
…#13332)

### Motivation

When we use a multi-topic reader, the `hasMessageAvailable` method might have the wrong behavior, since the multi-topics consumer receives all messages from the single-topic consumer, the single-topic consumer `hasMessageAvailable` might always be `false` (The lastDequeuedMessageId reach to the end of the queue, all message enqueue to multi-topic consumer's `incomingMessages` queue).

We should check the multi-topics consumer  `incomingMessages` size > 0 when calling `hasMessageAvailable `.

### Modifications

1. Add a check of `incomingMessages` size > 0
2. Add units test `testHasMessageAvailableAsync` to verify the behavior.

(cherry picked from commit 6c7dcc0)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Dec 30, 2021
@lhotari
Copy link
Member

lhotari commented Jan 4, 2022

This PR introduced a new flaky test, #13605 . Please fix it. It might be a matter of increasing the timeout from 10000 ms to a higher value.

poorbarcode added a commit that referenced this pull request Sep 28, 2023
…ing queue is not empty (#21259)

### Motivation

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by #13332, current PR only trying to fix the issue of `ConsumerImpl`.

### Modifications

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.
poorbarcode added a commit that referenced this pull request Oct 7, 2023
…ing queue is not empty (#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by #13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
poorbarcode added a commit that referenced this pull request Oct 8, 2023
…ing queue is not empty (#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by #13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
poorbarcode added a commit that referenced this pull request Oct 8, 2023
…ing queue is not empty (#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by #13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
liangyuanpeng pushed a commit to liangyuanpeng/pulsar that referenced this pull request Oct 11, 2023
…ing queue is not empty (apache#21259)

### Motivation

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by apache#13332, current PR only trying to fix the issue of `ConsumerImpl`.

### Modifications

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 15, 2024
…ing queue is not empty (apache#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by apache#13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
(cherry picked from commit 38c3f0c)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 17, 2024
…ing queue is not empty (apache#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by apache#13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
(cherry picked from commit 38c3f0c)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 19, 2024
…ing queue is not empty (apache#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by apache#13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
(cherry picked from commit 38c3f0c)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 23, 2024
…ing queue is not empty (apache#21259)

Reproduce steps:
- Create a reader.
- Reader pulls messages into `incoming queue`, do not call `reader.readNext` now.
- Trim ledger task will delete the ledgers, then there is no in the topic.
- Now, you can get messages if you call `reader.readNext`, but the method `reader.hasMessageAvailable` return `false`

Note: the similar issue of `MultiTopicsConsumerImpl` has been fixed by apache#13332, current PR only trying to fix the issue of `ConsumerImpl`.

Make `reader.hasMessageAvailable` return `true` when `incoming queue` is not empty.

(cherry picked from commit 6d82b09)
(cherry picked from commit 38c3f0c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.3 release/2.9.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants