You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "crossoverJie (via GitHub)" <gi...@apache.org> on 2025/09/23 09:33:11 UTC

[PR] fix: improve zero queue consumer support for partitioned topics [pulsar-client-go]

crossoverJie opened a new pull request, #1424:
URL: https://github.com/apache/pulsar-client-go/pull/1424

   
   
   Fixes #1421 
   
   
   ### Motivation
   
   zero queue consumer support for partitioned topics.
   
   
   
   ### Modifications
   
   - Use the partition index in the topic name
   - Remove detection of the topic name
   
   ### 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.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API: (yes / no)
     - The schema: (yes / no / don't know)
     - The default values of configurations: (yes / no)
     - The wire protocol: (yes / no)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / GoDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: improve zero queue consumer support for partitioned topics [pulsar-client-go]

Posted by "geniusjoe (via GitHub)" <gi...@apache.org>.
geniusjoe commented on PR #1424:
URL: https://github.com/apache/pulsar-client-go/pull/1424#issuecomment-3615583855

   Maybe related https://github.com/apache/pulsar-client-go/pull/1443


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: improve zero queue consumer support for partitioned topics [pulsar-client-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1424:
URL: https://github.com/apache/pulsar-client-go/pull/1424#discussion_r2371723872


##########
pulsar/consumer_impl.go:
##########
@@ -23,12 +23,9 @@ import (
 	"fmt"
 	"math/rand"
 	"strconv"
-	"strings"
 	"sync"
 	"time"
 
-	"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
-
 	"github.com/apache/pulsar-client-go/pulsar/crypto"
 	"github.com/apache/pulsar-client-go/pulsar/internal"
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"

Review Comment:
   The removal of unused imports 'strings' and 'github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils' is good practice, but verify that these imports are not used elsewhere in the file that wasn't shown in the diff.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: improve zero queue consumer support for partitioned topics [pulsar-client-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1424:
URL: https://github.com/apache/pulsar-client-go/pull/1424#discussion_r2375272603


##########
pulsar/consumer_zero_queue.go:
##########
@@ -142,11 +146,14 @@ func (z *zeroQueueConsumer) Ack(m Message) error {
 
 func (z *zeroQueueConsumer) checkMsgIDPartition(msgID MessageID) error {
 	partition := msgID.PartitionIdx()
-	if partition != 0 {
-		z.log.Errorf("invalid partition index %d expected a partition equal to 0",
-			partition)
-		return fmt.Errorf("invalid partition index %d expected a partition equal to 0",
-			partition)
+	if partition == 0 || partition == -1 {
+		return nil
+	}
+	if partition != z.pc.partitionIdx {
+		z.log.Errorf("invalid partition index %d expected a partition equal to %d",
+			partition, z.pc.partitionIdx)
+		return fmt.Errorf("invalid partition index %d expected a partition equal to %d",
+			partition, z.pc.partitionIdx)
 	}
 	return nil

Review Comment:
   The logic for handling partition index 0 has changed unexpectedly. Previously, partition 0 was the expected partition, but now it's treated as a special case that always returns nil. This could allow messages from partition 0 to be processed even when the consumer is configured for a different partition.
   ```suggestion
   	if partition == -1 || partition == z.pc.partitionIdx {
   		return nil
   	}
   	z.log.Errorf("invalid partition index %d expected a partition equal to %d",
   		partition, z.pc.partitionIdx)
   	return fmt.Errorf("invalid partition index %d expected a partition equal to %d",
   		partition, z.pc.partitionIdx)
   ```



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: improve zero queue consumer support for partitioned topics [pulsar-client-go]

Posted by "crossoverJie (via GitHub)" <gi...@apache.org>.
crossoverJie merged PR #1424:
URL: https://github.com/apache/pulsar-client-go/pull/1424


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org