Automattic / Automattic/wp-codebox

Retry Playground archive lock generation handoffs

Aperta
#2,464 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
17
Fork
4
Merge medio
59m
PR unite (30g)
131

Descrizione

## Problem

The authoritative smoke aggregate for #2463 exposed a cross-process handoff that the lock protocol detected correctly but classified incorrectly. `tryAcquireCacheLock()` can create the shared lock directory and then be descheduled before opening it. After the bounded empty-directory grace expires, another process may legitimately reclaim and replace that uninitialized generation. The original creator then observes a generation change between `lstat()` and `open()`.

Observed failure: [smoke aggregate run 33561166359](https://github.com/Automattic/wp-codebox/actions/runs/33561166359/job/100033725647)

```text
LeaseSidecarUnsafeError: Playground cache lease sidecar changed while opening
```

The protocol already retried generation changes detected while accessing an opened sidecar, but identified that outcome by matching one error-message phrase. A generation change detected while opening therefore escaped as a terminal unsafe-sidecar failure.

## Desired outcome

Represent legitimate sidecar generation changes as one explicit typed handoff outcome and retry them consistently during lock acquisition and inspection. Preserve the directory protocol because its non-empty removal interlock prevents a stale cleaner from deleting a replacement owner. Keep symlinks, non-directories, and other unsafe filesystem states fail-closed.

## Acceptance criteria

- Generation changes while opening or accessing a lease sidecar use one typed handoff classification.
- A creator that loses its uninitialized directory generation retries instead of terminating.
- Unsafe filesystem type and symlink replacements remain rejected or conservatively protected.
- Empty abandoned directories remain reclaimable without extending timing allowances.
- The separate-process archive-cache regression and full smoke aggregate pass.

## Rejected design

An initialized file published by hard link was evaluated and rejected: portable Node filesystems do not provide atomic conditional unlink by inode, so stale cleanup could unlink a replacement owner and permit concurrent lock holders.

## AI assistance

GPT-5.6 Sol via OpenCode analyzed the failed aggregate, evaluated and rejected an unsafe hard-link design during review, and drafted the typed handoff repair under Chris Huber's direction.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia da tryAcquireCacheLock() e traccia i percorsi di apertura e accesso del sidecar del lease, concentrandoti sul punto in cui vengono classificati i cambiamenti di generazione. Esegui prima la regressione di archive-cache in processi separati, quindi l’aggregato smoke completo; il lavoro è completo quando gli handoff legittimi vengono ritentati, mentre gli stati non sicuri del filesystem continuano a essere rifiutati e le directory vuote abbandonate rimangono recuperabili.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
backend, infrastructure
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.