Skip to content

Use heartbeat-based lock liveness instead of PID + process start time #862

Closed

Description

@tt-a1i

Proposal

Replace the PID + process start time liveness check in lock recovery with a heartbeat: the lock holder periodically refreshes the lock file's timestamp (e.g. mtime), and a lock is considered stale once it has gone longer than the deadline without a refresh. No process query is needed.

Motivation

PID + start time exists only to rule out PID reuse, but it depends on per-platform process queries that keep proving fragile:

A heartbeat is platform-independent, simple to reason about, and easy to test deterministically (control the clock/mtime).

Open questions

  • Refresh interval vs. stale deadline (e.g. refresh every 1s, stale after 5s).
  • Behaviour for long blocking operations in the holder (refresh from a timer/thread).
  • Migration: handling lock files written by older versions.

Refs #829, #857.

Activity

  1. tt-a1i commented on Oct 16, 2026

    @tt-a1i
    CollaboratorAuthor

    Implemented in #863 (78dc574).

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