EffectFlock heartbeat never refreshes, so locks held over 60 s can be broken
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- distributed-systems
Direzione di ricerca
Leggi prima packages/core/src/util/effect-flock.ts, concentrandoti sull’heartbeat avviato da EffectFlock.acquire e su come isStale lo valuta. Poi esamina i punti di chiamata del lock in packages/core/src/npm.ts e packages/core/src/repository-cache.ts. È terminato quando l’heartbeat di un lock mantenuto avanza a ogni intervallo e lo scenario di regressione non lo considera più obsoleto dopo 60 secondi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
EffectFlock.acquire never refreshes its heartbeat, so any lock held longer than 60 s looks abandoned and another process can break it while the holder is still working.
The heartbeat is started like this (packages/core/src/util/effect-flock.ts):
yield* fs
.utimes(handle.heartbeatPath, new Date(), new Date())
.pipe(Effect.ignore, Effect.repeat(Schedule.spaced(HEARTBEAT_MS)), Effect.forkScoped)
Effect.repeat runs the same effect again on every tick, and the two Dates were created once when that effect was built. So every tick sets the heartbeat back to the acquisition time. isStale treats a heartbeat older than STALE_MS (60 s) as a dead holder, so from 60 s after acquisition the lock can be taken by the next process that asks for it.
Holders that can run past 60 s include the npm install lock (npm-install:<dir> in packages/core/src/npm.ts) and the repository cache clone lock (packages/core/src/repository-cache.ts). If a second process asks for the same key during a slow install or clone, both proceed in the same directory.
Plugins
None needed.
OpenCode version
dev at 0f549842ee (also 1.18.32)
Steps to reproduce
- Hold a lock with
flock.acquire(key)for more than 20 s. - Watch
<lock dir>/heartbeat: its mtime never moves past the time the lock was taken, whileHEARTBEAT_MSis 20 s. - After 60 s,
isStalereports the held lock as stale, so a secondacquire(key)from another process breaks it and succeeds.
A regression test for step 2 is in the linked PR: with the lock held, backdate the heartbeat, advance the clock one interval, and check the heartbeat's age. Today it keeps the acquisition time.
Screenshot and/or share link
n/a
Operating System
Linux
Terminal
n/a
- Lingua principale
- TypeScript
- Stelle
- 210k
- Fork
- 27.8k
- Merge medio
- 8h 1m
- PR unite (30g)
- 357
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un 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 anomalyco/opencode
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
anomalyco/opencode#51159 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di anomalyco/opencode
Issue simili
-
Add: Digi World (Romania) SDApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Fission-AI/OpenSpec#1986 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
nestjs/docs.nestjs.com#3554 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
publicodes/publicodes#868 ·
-
namespace operations
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
EclipseFdn/open-vsx.org#13488 ·
I maintainer di solito rispondono entro 2 giorni