Skip to content

Add retention period to RecoveryConfig#2329

Open
wyfo wants to merge 4 commits intoeclipse-zenoh:mainfrom
ZettaScaleLabs:fix/adv-pubsub-retention-period
Open

Add retention period to RecoveryConfig#2329
wyfo wants to merge 4 commits intoeclipse-zenoh:mainfrom
ZettaScaleLabs:fix/adv-pubsub-retention-period

Conversation

@wyfo
Copy link
Contributor

@wyfo wyfo commented Dec 22, 2025

Each source state get an additional latest access timestamp which is incremented at each access. A garbage collection task is spawned to periodically check the least recently used source states, to decide if they should be garbage collected.

Alive publishers, as per spawned liveliness subscriber, are never garbage collected; there latest access is updated instead.

lru library is used to avoid making a full scan of the source states' lists at each garbage collection.

Removing a source state must also clean up the periodic query associated to it. zenoh_util::Timer is not built for this use case (and it is badly designed anyway), so it has been replaced by raw tokio tasks. Using tokio_util::task::AbortOnDropHandle makes tasks cleanup very easy.

Each source state get an additional latest access timestamp which is
incremented at each access. A garbage collection task is spawned to
periodically check the least recently used source states, to decide if
they should be garbage collected.

Alive publishers, as per spawned liveliness subscriber, are never
garbage collected; there latest access is updated instead.

`lru` library is used to avoid making a full scan of the source states'
lists at each garbage collection.

Removing a source state must also clean up the periodic query associated
to it. `zenoh_util::Timer` is not built for this use case (and it is
badly designed anyway), so it has been replaced by raw tokio tasks.
Using `tokio_util::task::AbortOnDropHandle` makes tasks cleanup very
easy.
@wyfo wyfo requested a review from OlivierHecart December 22, 2025 11:09
@github-actions
Copy link

PR missing one of the required labels: {'api-sync', 'bug', 'dependencies', 'breaking-change', 'documentation', 'internal', 'ci', 'new feature', 'enhancement'}

@wyfo wyfo requested a review from DenisBiryukov91 December 22, 2025 11:09
@wyfo wyfo added the enhancement Existing things could work better label Dec 22, 2025
@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 50.31250% with 159 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.82%. Comparing base (a4ee16f) to head (1190511).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
zenoh-ext/src/advanced_subscriber.rs 50.31% 159 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2329      +/-   ##
==========================================
- Coverage   72.97%   72.82%   -0.16%     
==========================================
  Files         388      388              
  Lines       62200    62309     +109     
==========================================
- Hits        45391    45377      -14     
- Misses      16809    16932     +123     

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

token: None,
_gc_task: AbortOnDropHandle::new(ZRuntime::Application.spawn(gc_task(
weak.clone(),
retransmission.as_ref().and_then(|r| r.retention_period),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not unwrap_or retention period immediately instead of passing an option which will be unwrapped anyways inside gc_task ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Existing things could work better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants