fix(daemon): on Linux a forward wall-clock step may make a live daemon's own lock read as stale

Open
#156 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go, linux

Research direction

Start in internal/daemon/procstart_linux.go, where processStartTime combines btime from /proc/stat with the start tick from /proc/<pid>/stat, and check the lock and registry staleness comparison that uses procStartTimeSlack. First confirm the wall-clock step effect by reading btime before and after a 10 s forward step on Linux. Done means either a corroboration check against the start tick count for same-boot records, or a documented limit next to procStartTimeSlack, with the fix confirmed in the daemon tests.

Written by the indexing model from the issue text.

Description

bug priority:low
What happens

On Linux, processStartTime (internal/daemon/procstart_linux.go) works out a process's start time when it reads it: btime from /proc/stat plus the tick count from /proc/<pid>/stat. The kernel computes btime from the current wall-clock offset, so a step of the wall clock moves it. Two examples of such a step are an NTP step and a WSL2 resume.

After a forward step of more than procStartTimeSlack (5 s), a live daemon's own lock and registry record would read as stale. Another acquire would then remove the lock (INDX-05), and List would prune the record.

This is unconfirmed: it comes from reading the code, not from a reproduction. The problem predates #146. The #146 change narrows it, because after a backward step the record now corroborates.

To confirm
  1. On Linux, read btime from /proc/stat.
  2. Step the wall clock forward 10 s.
  3. Read btime again and compare.
What should happen

If this is confirmed, corroborate a record from the same boot against a value that a clock step does not move, for example the start tick count. Otherwise, document the limit next to procStartTimeSlack.

Refs #146.


🤖 Generated with Claude Code

https://claude.ai/code/session_017tyHwvTWuHuKjdiZLTaGD1

Dominant language
Go
Stars
0
Forks
0
Avg merge
5h 16m
Merged PRs (30d)
107

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seanb4t/codegraph-go

All issues in seanb4t/codegraph-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.