Repository navigation
[bug] Concurrent session writers cause corrupt session log (seq collision) - history/model fail to load #4208
macrowanwj-droid
started this conversation in
General
Replies: 2 comments
|
并发写 / 恢复写者用旧 seq 追加,官方会整段拒读( dsh-session-surgeon 按官方语义裁到缺口前最后一个完整 dsh plugin --profile web add "github:xiaoshenming/dsh-session-surgeon#main"重启 |
0 replies
|
Same family as #1497 — seq overlap/rollback in the committed region. Two zero-history-loss options (verified against the unpatched npm 0.1.1-rc.2: 931,455 events, no seq gap,
Pick #2 if the log is already broken; patch the readers if you want future crashes to stay invisible. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Bug Report: Concurrent session writers cause corrupt session log (seq collision)
Environment
DSH_HOMEpinned to a local sandbox directorySeverity
High — causes the Web GUI to be unable to load session history and model list (both require reading the session log). Occurred twice in a single session on 2026-08-23. Requires manual repair of the log file (seq renumbering) to recover.
Symptom
GUI shows empty history and no models. Backend RPC returns:
Root Cause Analysis (two distinct corruption modes)
Mode 1: Process restart resumes writing from stale seq
turn/end interruptedat turn 16)Mode 2: Two Session instances concurrently write the same log (same process) ← most likely trigger
Observed corruption point:
Reasoning chain:
session/end-seedwhen the seed doesn't already end with one → consumes seq 92744agent/inbox/splicedthrough another Session instance whose in-memorylog.lengthis still 92744 (its snapshot predates the end-seed append)Suspected root cause
In
dsh-session, theend-seedappend in the Session constructor is not synchronized with the persistence cursor / in-memorylog.lengthof other live Session instances. There is no mutual exclusion between the resume path (end-seed append) and the agent inbox injection path (agent/inbox/spliced).The corruption is most likely to trigger when:
Steps to reproduce (estimated)
corrupt session logon next history/model load(We did not produce a minimal repro; this is inferred from log forensics of the two incidents.)
Impact
session.historyfailssession.modelsfails (resume path reads log)Workaround (applied)
Manual repair: renumber all
seq/seq0/sourceEventSeqsafter the conflict point to restore continuity, then re-pack the zstd multi-frame container. We also built a health-check script that scans session logs for duplicate seqs / regressions.Suggested fix direction
dsh-session, make theend-seedappend and the persistence cursor atomic (or re-read the latest seq from disk before appending)Additional note
max_memory_restart: '512M'in our PM2 config caused frequent restarts (DSH baseline RSS ~500MB with many plugins loaded), which increased exposure to Mode 1. We raised it to 1536M locally.Log snippets (redacted, timestamps local)
All reactions