Repository navigation
Replies: 5 comments
|
Verified against master c291e79 - the persistence sources are byte-identical to 0.1.5-rc.1, so this covers your version. The described window does not exist: truncateTornTail/repair (session-persistence-jsonl/src/index.ts:840,1286) truncates only the CURRENT v3 generation (format.ts:290-303), runs from the write path only when tornTruncateTo is set (storage.ts:328-331), and migration explicitly clears tornTruncateTo (index.ts:632) - migration never truncates anything. Actual v0->v3 order: select gen0 (:1368-1400) -> migrate in memory (:598-640) -> publish a write+fsync'd temp file (generation.ts:710-781, fsync :763, 'wx') -> verify -> re-stat source unchanged (:901-904) -> hardlink+dir-fsync publish (:812-838). gen0 is preserved; a crash before publish leaves gen0 intact plus an orphan *.tmp ignored by canonical-name scanning (:1572-1577), so the next boot re-runs the migration - your suggested write-then-swap is already the design. The only truncate-before-rewrite window is torn-tail repair on the current generation (storage.ts:328-337), bounded to one torn zstd frame - it cannot explain ~1 day / 854 frames. Worth re-checking the incident with the exact npx version hash and one affected session's on-disk state. |
|
Verified against commit c291e79 (master at the time of this check). Two facts anchor the version coverage: Point-by-point verificationThe cited symbols are real and the cited lines are correct. But the described mechanism does not exist in the code. The two steps you linked are not two halves of the migration; they belong to different paths and neither ever touches gen0:
Crash analysis of the real flow:
The one truncate-before-rewrite window that does exist is torn-tail repair on the current v3 file after an unclean append kill ( ConclusionThe reported bug as described — "truncate gen0, then publish v3 in a separate non-atomic step" — does not exist at this commit, and the suggested fix (durably write and fsync the new generation before touching the old one) is already the implemented design, so there is no fix commit on master to point to. The incident is real (thank you for reporting it), but this mechanism cannot have caused it. Candidate causes worth checking on the incident's evidence: (a) events still in the in-memory live-write buffer that were never flushed when DSH was stopped ( Not verifiable here: byte-identity of the published npm Проверено по коммиту c291e79 (master на момент проверки). Исходники Проверка по пунктамУказанные символы и строки верны. Но описанного механизма в коде нет. Два шага, которые вы связали, — это не две половины миграции: они принадлежат разным путям, и ни один из них никогда не трогает gen0:
Анализ сбоев реального потока:
Единственное реальное окно «обрезать до перезаписи» — это repair оборванного хвоста на текущем v3 после некорректно убитого append ( ВыводОписанного бага — «обрезать gen0, затем отдельным неатомарным шагом опубликовать v3» — на этом коммите не существует, а предлагаемое исправление (сначала долговечно записать и fsync-нуть новое поколение, и только потом трогать старое) уже является реализованным дизайном, поэтому коммита-фикса на master нет. Инцидент реален (спасибо за репорт), но этот механизм не мог его вызвать. Кандидаты для проверки по уликам инцидента: (а) события, оставшиеся в in-memory live-write буфере и не сброшенные при остановке DSH ( Не удалось проверить: байтовую идентичность опубликованного npm-артефакта |
|
Thanks for the thorough code-level review — you're right, and we've corrected our root-cause analysis. The "truncate gen0 → publish v3" window does not exist; the migration is already write-then-swap, exactly as you verified. One concrete fact from our side also rules out the migration path entirely:
Version: Revised hypothesis (your candidate (c)): the loss came from our own workspace-migration tooling and/or an unclean stop, not from the session-format migration. We're re-auditing that layer against the on-disk evidence and will report back if we pin it down. Thank you again — this corrected our analysis and saved us from chasing the wrong path. |
|
Thanks for the follow-up — that on-disk evidence is decisive. With only gen0 ( Your revised hypothesis is the one I'd chase too. If the re-audit pins the layer, a short note here — or a new issue if it turns out to be a harness-adjacent seam — would help anyone else who sees the same loss. Nothing further needed from the harness side on this report. |
|
Thanks for confirming — and for the thorough code-level review. We'll continue the re-audit on our side; if it surfaces a harness-adjacent seam, we'll open a new issue. Much appreciated. |
Uh oh!
There was an error while loading. Please reload this page.
RU: [Баг] Миграция формата сессии (v0→v3) неатомарна: остановка процесса между обрезкой gen0 и записью v3 безвозвратно теряет хвост лога
Environment
@deepseek-ai/dsh0.1.5-rc.1(resolved vianpx)@deepseek-ai/dsh-session-persistence-jsonl/lib/index.js—truncateTornTail()(line 2749) →repair()(line 3084),publishCurrentExclusive()(line 2021)Summary
A session log is stored in format generations:
session.jsonl.zstd(gen0 / v0) andsession.v3.jsonl.zstd(v3, current). On load DSH takes the newest generation and, if it is older than v3, migrates v0→v1→v2→v3.The migration is non-atomic:
truncateTornTail()→repair().publishCurrentExclusive()(temporary file + rename).There is no single transaction "truncate gen0 + write v3". If the process is stopped between step 1 and step 2, gen0 is already truncated while v3 is incomplete or absent → the log tail is lost irreversibly.
Steps to reproduce
session.jsonl.zstd).Expected vs Actual behavior
Impact
Real incident: 8 sessions lost their log tail (in several cases exactly ~1 day of activity; one session lost 854 frames). All were recovered only because a full backup snapshot existed. The trigger was stopping DSH while workspace migrations were in progress.
Suggested fix
Make generation migration atomic: durably write and fsync the new v3 before truncating/removing the old gen0, or wrap both steps in a single journaled transaction with a recovery marker. The new generation must never be left in a half-written state as the only survivor.
[Баг] Миграция формата сессии (v0→v3) неатомарна: остановка процесса между обрезкой gen0 и записью v3 безвозвратно теряет хвост лога
EN: [Bug] Session format migration (v0→v3) is non-atomic: stopping the process between the gen0 truncation and the v3 write irreversibly loses the log tail
Окружение
@deepseek-ai/dsh0.1.5-rc.1(черезnpx)@deepseek-ai/dsh-session-persistence-jsonl/lib/index.js—truncateTornTail()(строка 2749) →repair()(строка 3084),publishCurrentExclusive()(строка 2021)Краткое описание
Лог сессии хранится поколениями формата:
session.jsonl.zstd(gen0 / v0) иsession.v3.jsonl.zstd(v3, текущий). При загрузке DSH берёт старшее поколение и, если оно младше v3, мигрирует v0→v1→v2→v3.Миграция неатомарна:
truncateTornTail()→repair().publishCurrentExclusive()(временный файл + rename).Единой транзакции «обрезать gen0 + записать v3» нет. Если процесс остановлен между шагами 1 и 2, gen0 уже обрезан, а v3 неполный или отсутствует → хвост лога теряется безвозвратно.
Шаги воспроизведения
session.jsonl.zstd).Ожидаемое vs фактическое поведение
Влияние
Реальный инцидент: 8 сессий потеряли хвост лога (в нескольких случаях ровно ~сутки активности; одна сессия потеряла 854 кадра). Всё восстановлено только благодаря наличию полного бэкап-снимка. Триггер — остановка DSH во время миграций воркспейсов.
Предложение по исправлению
Сделать миграцию поколений атомарной: сначала надёжно (durably) записать и fsync новый v3, и только потом обрезать/удалять старый gen0, либо обернуть оба шага в единую журналируемую транзакцию с маркером восстановления. Новое поколение не должно оставаться единственным уцелевшим в недописанном состоянии.
All reactions