pdolif commented on issue #23485:
URL: https://github.com/apache/pulsar/issues/23485#issuecomment-2424146241

   Hi @lhotari 
   I would like to share my findings about the test case. It tests the pausing 
of a multi-topic consumer by doing the following:
   - There are 3 topics.
   - Step 1: Produce 5 messages per topic. Create a multi-topic consumer for 
topic 1 and 2 (but not topic 3) with receiverQueueSize of 1. Receive 8 
messages. Here it looks to me like 4 messages of topic 1 and 4 messages of 
topic 2 **should** be consumed? In successful test runs this is the case. Then 
one message remains in the queue of each of the two (internal) consumers. 
However, in unsuccessful test runs, for me, it was always the case that 5 
messages of one topic, and 3 messages of the other topic were received.
   - Step 2: Pause the multi-topic consumer.
   - Step 3: Add topic 3 to the subscription of the multi-topic consumer. Now 
there are 3 internal consumers, one per topic.
   - Step 4: Produce 5 more messages per topic. 
   - Step 5: Here the receiver queues of consumer 1 and 2 **should** be cleared 
by receiving 2 messages. In successful test runs this is the case. In failing 
test runs 2 messages of the same topic are received.
   - Step 6: It is expected, that both consumer queues are empty, and since the 
multi-consumer is paused, no message should be consumed. A problem might be 
that the following code is used:
   ```java
   // 6. should not consume any messages
   Awaitility.await().untilAsserted(() -> 
assertNull(consumer.receive(RECEIVE_TIMEOUT_SECONDS, TimeUnit.SECONDS)));
   ```     
   instead of:
   ```java
   // 6. should not consume any messages
   assertNull(consumer.receive(RECEIVE_TIMEOUT_SECONDS, TimeUnit.SECONDS));
   ```     
   With the current test code, it is possible that a message is received in the 
first call of the await, but no message is received in the next call, and then 
`assertNull` succeeds. Then the test does not fail even though a message is 
received. This is why, in the end, the counter of received messages is 29 
instead of 30, because one message is received in step 6.
   - Step 7: Resume multi-topic consumer.
   - Step 8: Consume the remaining messages.
   
   It seems, that the multi-topic consumer is automatically resumed between 
steps 2 and 7 in 
`MultiTopicsConsumerImpl.resumeReceivingFromPausedConsumersIfNeeded()`.
   
   


-- 
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