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

   ## Summary
   
   After a split / merge the parent segment is sealed and accepts no further 
writes; eventually its data ages out. There was no mechanism to actually delete 
it. This PR adds:
   
   ### 1. Single owner of segment-topic deletion
   
   The v4 inactive-topic GC would otherwise race the controller for whole-topic 
deletion of segment-backing topics. `PersistentTopic#checkGC` now early-returns 
when the topic is in the `segment://` domain — the controller is the sole 
lifecycle owner.
   
   ### 2. Periodic GC tick on the `ScalableTopicController` leader
   
   Each tick:
   
   - Resolves the effective retention from **topic-policies → namespace policy 
→ broker default**. Negative ⇒ keep forever, tick is a no-op.
   - Picks sealed segments where `(now - sealedAtMs) >= retentionMs`.
   - For each candidate, polls every existing subscription's backlog on that 
segment via the existing `/segments/.../backlog` admin endpoint. All-zero ⇒ 
prunable.
   - CAS-prunes the layout (re-validating against the latest layout to handle a 
concurrent prune by a former leader gracefully), reloads, notifies 
subscriptions, then deletes the backing topic via 
`admin.topics().deleteAsync(force=true)`.
   - Layout-prune is the point of no return; backing-topic delete is 
best-effort and retried on subsequent ticks.
   
   The clock is injectable (`java.time.Clock`) so tests can fast-forward past 
retention deterministically. `splitSegment` / `mergeSegments` now read the 
wall-clock through the same `Clock` so that test ticks compute consistent ages.
   
   ## Test plan
   
   - [x] `testGcTickPrunesDrainedSealedSegmentPastRetention` — split, tick 
within retention (no prune), advance past retention, tick again, assert pruned 
+ delete called.
   - [x] `testGcTickRespectsKeepForeverRetention` — negative retention leaves 
the segment in place even after a year of clock advance.
   - [x] Existing scalable + V5 suites green: 
`org.apache.pulsar.broker.service.scalable.*` (76 tests), `V5SmokeTest`, 
`V5SegmentSplitTest`, `V5DeadLetterPolicyTest`.
   - [x] Checkstyle clean (`pulsar-broker` main + test).


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