lhotari commented on code in PR #25126:
URL: https://github.com/apache/pulsar/pull/25126#discussion_r3117170054
##########
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java:
##########
@@ -3002,24 +3003,44 @@ private class AnalyzeBacklog extends CliCommand {
@Parameters(description = "persistent://tenant/namespace/topic", arity
= "1")
private String topicName;
- @Option(names = { "-s", "--subscription" }, description =
"Subscription to be analyzed", required = true)
+ @Option(names = {"-s", "--subscription"}, description = "Subscription
to be analyzed", required = true)
private String subName;
- @Option(names = { "--position",
- "-p" }, description = "message position to start the scan from
(ledgerId:entryId)", required = false)
+ @Option(names = {"--position",
+ "-p"}, description = "Message position to start the scan from
(ledgerId:entryId)", required = false)
private String messagePosition;
+ @Option(names = {"--backlog-scan-max-entries",
+ "-b"}, description = "The maximum number of backlog entries
the client will scan before terminating "
+ + "its loop", required = false)
+ private long backlogScanMaxEntries = -1;
Review Comment:
--backlog-scan-max-entries default of -1 relies on a subtle side-effect for
backward compat — CmdTopics.java:3019 With -1, the predicate
result.getEntries() >= -1 is always true, so the loop completes on the first
iteration (matching old single-call behavior). That works, but it conflates
"unset" with "terminate immediately." Preferred: treat unset as "no cap" (use
the no-predicate overload analyzeSubscriptionBacklogAsync(topic, sub, pos)) and
only take the looping path when -b is supplied.
That makes intent explicit and avoids relying on entries >= -1 semantics.
Also add a validation error for -b 0 or negative user input, since those are
meaningless.
--
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]