thetumbled opened a new pull request, #21969:
URL: https://github.com/apache/pulsar/pull/21969

   
   ### Motivation
   `reader.hasMessageAvailable()` rely on `getLastMessageId` to determine 
whether there are any messages available to read.
   `org.apache.pulsar.broker.service.ServerCnx#handleGetLastMessageId` will 
read the last message from compacted topic in some cases without check if the 
consumer is in read compact mode. 
   If the consumer/reader disable the read compact mode, and the cluster enable 
the compaction feature, messages will be compacted into the compacted topic, 
but the dispactcher will not dispatch messages from compacted topic to 
consumer. If the messages in the original topic is expired and the consumer has 
nothing to be read, while the messages in the compacted topic retain alive. 
   **`reader.hasMessageAvailable()` will return true as there are messages in 
the compacted topic, but consumer/reader will not get any messages because 
there are nothing in the original topic.**
   
   
   ### Modifications
   `reader.hasMessageAvailable()`  should check if the consumer is in read 
compact mode to determine whether get the last message id from the compacted 
topic.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   This change added tests and can be verified as follows:
   
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to