Skip to content

SessionPrune.resetThresholds leaves stale checkpoint writer failure counters #734

@bcoderg-sys

Description

@bcoderg-sys

Problem

SessionPrune keeps several pieces of per-session checkpoint bookkeeping: crossed, maxCrossed, and writerFailures.

resetThresholds(sessionID) currently clears crossed and maxCrossed, but it leaves writerFailures untouched. Since writerFailures is keyed by the same sessionID, the same session can enter a fresh checkpoint threshold cycle while still carrying the previous consecutive writer failure count.

If the previous count is already close to max_writer_failures, a later checkpoint writer failure in that same session can reach the retry cap earlier than expected. It also leaves a small stale in-memory entry until a successful writer clears it or the process restarts.

Expected behavior

When resetThresholds(sessionID) starts a fresh checkpoint threshold cycle for a session, all related per-session checkpoint threshold state should be reset together.

Suggested fix

Clear the writer failure counter together with the other reset state:

writerFailures.delete(sessionID)

Suggested test coverage

Add a targeted SessionPrune.fireCheckpoints test that:

  1. records two checkpoint writer failures for a session,
  2. calls resetThresholds(sessionID),
  3. verifies the next checkpoint threshold cycle starts with a fresh failure count instead of inheriting the previous value.

This keeps the fix scoped to the same session and avoids changing retry behavior across different sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions