Skip to content

[ISSUE #10384] Enforce Lite exclusive subscription eviction via server-side tombstones#10386

Open
f1amingo wants to merge 1 commit into
apache:developfrom
f1amingo:feature/lite-exclusive-eviction-tombstone
Open

[ISSUE #10384] Enforce Lite exclusive subscription eviction via server-side tombstones#10386
f1amingo wants to merge 1 commit into
apache:developfrom
f1amingo:feature/lite-exclusive-eviction-tombstone

Conversation

@f1amingo
Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

Lite exclusive eviction relied on a fire-and-forget unsubscribe notification. When the client missed it, the old consumer kept pulling, causing double consumption and breaking the exclusive contract.This PR adds a broker-local, in-memory tombstone keyed by (clientId, lmqName) as a server-side fallback:

  • Written synchronously on eviction, before client notification.
  • Checked at the Lite pull entry; rejected pulls reuse the existing "no message available" semantics, requiring no client change.
  • Lifecycle-aligned with the client's subscription set — cleared on explicit resubscription, full-sync reconciliation, and disconnect/timeout.
  • Self-heals lost notifications by re-sending unsubscribe when a heartbeat still reports a tombstoned lmqName.

How Did You Test This Change?

  • New unit tests for ExclusiveEvictionTombstones: add / contains / remove / removeAllOf / retainOnly with prefix-isolation and concurrency cases.
  • Extended LiteSubscriptionRegistryImplTest to cover:
    • Tombstone written on exclusive eviction;
    • Self-clear on the evicted client's resubscription;
    • Full-sync reconciliation: stale GC via retainOnly and re-notify on intersection;
    • Cleanup on disconnect/timeout, including the thisSub == null short-circuit path.
  • Updated PopLiteMessageProcessorTest for the clientId-aware pull path: pulls from a tombstoned client are rejected and return the "no message" result.
  • All affected modules pass mvn test.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 26, 2026

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.99%. Comparing base (051ba27) to head (33c0242).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...etmq/broker/lite/LiteSubscriptionRegistryImpl.java 88.88% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10386      +/-   ##
=============================================
+ Coverage      48.89%   48.99%   +0.09%     
- Complexity     13452    13495      +43     
=============================================
  Files           1376     1377       +1     
  Lines         100527   100577      +50     
  Branches       12983    12988       +5     
=============================================
+ Hits           49154    49274     +120     
+ Misses         45383    45291      -92     
- Partials        5990     6012      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

RongtongJin
RongtongJin previously approved these changes May 27, 2026
@f1amingo f1amingo force-pushed the feature/lite-exclusive-eviction-tombstone branch 2 times, most recently from b41513f to 7e9cf02 Compare May 28, 2026 04:34
Lite exclusive eviction relied on a fire-and-forget unsubscribe notification.
When the client missed it, the old consumer kept pulling, causing double
consumption.

Add a broker-local, in-memory tombstone keyed by (clientId, lmqName):
- Written synchronously on eviction, before client notification.
- Checked at the Lite pull entry; rejected pulls reuse "no message available", requiring no client change.
- Lifecycle-aligned with the subscription set: cleared on resubscription, full-sync reconciliation, and disconnect/timeout.
- Self-heals lost notifications by re-sending unsubscribe when a heartbeat still reports a tombstoned lmqName.

Tests: add ExclusiveEvictionTombstonesTest; extend registry and pull-path
tests to cover eviction, self-clear, reconciliation, and cleanup.
@f1amingo f1amingo force-pushed the feature/lite-exclusive-eviction-tombstone branch from 7e9cf02 to 33c0242 Compare May 28, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Server-side enforcement for Lite exclusive subscription eviction

3 participants