memlog.py: concurrent writers lose entries and can truncate the log (shared .tmp name, no lock)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
Direzione di ricerca
Start with skills/bmad-eval-runner/scripts/memlog.py and compare the installed copy at _bmad/scripts/memlog.py; inspect the append read-modify-write path and its temporary-file handling. Reproduce the race with the provided parallel append commands, then verify that concurrent appends preserve every entry and do not leave invalid frontmatter.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
memlog.py (skills/bmad-eval-runner/scripts/memlog.py, also installed as _bmad/scripts/memlog.py) does read-modify-write with no lock, and every process writes the same temp file, <path>.tmp. One process can os.replace a temp file that another is still writing. So beyond lost updates, the log can be replaced with a partial file. That contradicts the docstring's claims that a crash never leaves a half-written entry and that nothing is ever removed.
Concurrent appends are realistic: parallel subagents, bmad-loop workers, or two sessions on the same skill.
Steps to reproduce
M=skills/bmad-eval-runner/scripts/memlog.py
python3 $M init --path .memlog.md
for i in $(seq 1 20); do
python3 $M append --path .memlog.md --type note --text "a$i" &
python3 $M append --path .memlog.md --type note --text "b$i" & wait
done
grep -c '^- ' .memlog.md # 32 of 40 kept; 7 runs crashed with FileNotFoundError on .memlog.md.tmp
With 40 writers at once, 1 of 40 entries survived. Some writers failed with ValueError: .memlog.md has no frontmatter, because they read a half-written file that another writer had renamed into place.
Expected behavior
- Use a unique temp file per write (
tempfile.mkstemp(dir=path.parent)). - Hold an advisory lock (
fcntl.flock/msvcrt.locking, or a.lockfile withO_EXCL) across read-modify-write. - Optionally, append entries with
O_APPENDand updateupdated:less often.
Environment
- Model(s) used: n/a (deterministic script)
- Agentic IDE used: n/a (scripts run directly)
- BMad version: bmad-builder
main@d4a921c(v2.2.2 + #118) - Project language: Python 3.13, Linux
- Lingua principale
- Python
- Stelle
- 220
- Fork
- 54
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bmad-code-org/bmad-builder
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bmad-code-org/bmad-builder#157 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bmad-code-org/bmad-builder#153 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bmad-code-org/bmad-builder#151 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
bmad-code-org/bmad-builder#127 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
bmad-code-org/bmad-builder#123 ·
Tutte le issue di bmad-code-org/bmad-builder
Issue simili
-
namespace
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
EclipseFdn/open-vsx.org#15604 ·
I maintainer di solito rispondono entro 1 giorno
-
app: scripts severity: low status: backlog type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
netbox-community/netbox-scripts#164 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 5 giorni
-
Public function to read participants.tsvForse già presa @bruAristimunha l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
huggingface/tau#799 ·
I maintainer di solito rispondono entro 2 giorni