lhotari commented on PR #25696:
URL: https://github.com/apache/pulsar/pull/25696#issuecomment-4390742954

   **[BUG] 404 conflates "segment topic not loaded" with "subscription not 
found", causing silent failures.**
   
   `pulsar-broker/.../ScalableTopicController.java` ~L671-675 (and the matching 
block in `clearSubscriptionBacklogOnSegment` ~L693-697) swallows 
`PulsarAdminException.NotFoundException` as success with the comment *"No 
cursor on this segment yet — nothing to seek. Tolerated."*
   
   But the segment endpoint in `Segments.java` returns 404 for **two distinct 
cases**:
   1. `Segment topic not loaded: …` — the endpoint comment even says *"callers 
can retry once the segment owner has loaded it"*.
   2. `Subscription not found on segment: …` — the case the controller actually 
intends to tolerate.
   
   The admin client only sees the status code, not the message body, so a 
transient unload (segment owner restarting, ownership churn) during a 
parent-topic seek is silently swallowed and the caller thinks the seek 
succeeded across all segments — when in fact one or more were skipped entirely. 
For a write op like seek / clear-backlog this is a real correctness bug, not 
just a UX wart.
   
   A few ways to fix:
   - Distinguish via distinct status codes on the segment endpoint (e.g. `503 
Service Unavailable` for not-loaded, `404` only for subscription-not-found).
   - Use `getTopic()` instead of `getTopicIfExists()` on the segment side so 
the owner loads on demand (matches how cursor-mutating ops on regular topics 
behave).
   - Carry a structured error in the response body and parse it 
admin-client-side.
   
   The Javadoc on `seekSubscription` at L620 explicitly states 
*"Subscription-not-found on a segment … is tolerated as success"* — the 
implementation is broader than that contract.
   


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