Repository navigation
Replies: 2 comments
|
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] Concurrent writing to the same session log corrupts seq (error:
corrupt session log: seq gap in committed region)Summary
When two DSH instances write to the same session at the same time (e.g. the web instance on :3080 and a desktop/client instance), the session log's
seqcounter races and can go backwards, producing:Newer builds validate the committed region strictly and refuse to load the whole session history once this happens, so the affected conversation becomes unreadable.
Environment
0.1.0-rc.7(/opt/homebrew/bin/dsh, managed by PM2)v26.3.0Root cause (observed evidence)
The corrupt session
session.jsonl.zstdcontains a seq that jumps backwards (not the normal forward gaps caused byassistant/chunkstreaming):Line 9 should continue from
seq=6(i.e.7, 8, 9, β¦) but was written starting again fromseq=4. The timestamp gap (~36 minutes) and the duplicated4,5,6sequence indicate two instances were appending to the same file concurrently, each unaware of the other's counter.I repaired it locally by re-numbering every
seqfrom line 9 onward by+3, which restores strict monotonic increase and recovers the history without dropping any content. But this is a data-corruption bug β the writer should make per-session seq allocation atomic / single-writer.Related issue
A separate symptom of the same concurrency situation: when the process is restarted under PM2 while the previous
dshprocess hasn't released port 3080 yet, the new instance crashes withlisten EADDRINUSE: address already in use 127.0.0.1:3080, and PM2 enters a crash-restart loop (observed 431 restarts). It eventually self-resolves once a process wins the port, but the port-bind error / restart loop may deserve a look too.Suggestion
seqallocation single-writer (e.g. a session-level append lock, or derive seq from a shared counter) so concurrent instances can't race.committed regionvalidation to tolerate (and maybe auto-repair) a small backwards gap instead of making the whole history unreadable, or at least surface a clearer recovery path.Thanks for the great tool!
All reactions