Skip to content

file-backed sessions from before a broker restart never expire #172

Closed

Description

@fabracht

Found in the PR #170 review, with a failing test.

Defect: in the file backend, ClientSession.last_seen is #[serde(skip, default = SystemTime::now)] (storage/mod.rs), so every read from disk resets it to now. cleanup_expired (file_backend.rs) re-reads sessions that exist only on disk on every sweep tick, so their expiry clock restarts each time and they never expire.

Effect: a client that never reconnects after a broker restart leaks its session file, and its queue, forever.

Fix: persist the disconnect time (or last_seen) so expiry counts from the actual disconnect across restarts. A session that was connected when the broker went down should count from the restart, or from the last persisted activity.

Test: a session with 1 s expiry, reloaded from disk and swept 3 times, is still on disk.

Activity

  1. fabracht commented on Sep 27, 2026

    @fabracht
    ContributorAuthor

    Fixed in #170 (eb9b051).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions