storage/posix: a .state lock failure panics on the queue goroutine (an unreachable volume crashes the process)

Aperta Adatta ai principianti
#1,286 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend

Direzione di ricerca

Inizia da storage/posix/files.go, dove le quattro chiamate panic(err) seguono le chiamate lockFile e unlock di treeStateLock in sequenceBatch, nell'inizializzazione di appender e nei percorsi initialise e buildTree di MigrationStorage. Verifica come storage/internal/queue.go esegue sequenceBatch sulla goroutine worker e come doFlush passa gli errori ai future Add in attesa. È completato quando la riproduzione nel issue restituisce un errore alla chiamata Add invece di andare in panic, e i test posix esistenti continuano a passare.

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

Descrizione

Version: v1.0.4, and main at ac6c467339daeb822cbf94695505a5120ab47623.

What happens: storage/posix/files.go calls panic(err) when s.lockFile(ctx, treeStateLock) fails, and again when the returned unlock() fails, in four places on main:

  • (*appender).sequenceBatch (lines 322-329)
  • (*appender).initialise (567-574)
  • (*MigrationStorage).initialise (1044-1051)
  • (*MigrationStorage).buildTree (1089-1096)

sequenceBatch runs on the internal queue's worker goroutine (storage/internal/queue.go), so the caller cannot recover it: a volume that becomes unreachable (an unmounted or lost persistent volume) takes the whole process down instead of failing the pending Add calls.

Reproduction:

  1. d, _ := posix.New(ctx, posix.Config{Path: dir}), then tessera.NewAppender(ctx, d, tessera.NewAppendOptions().WithCheckpointSigner(s)).
  2. Add one entry and await it.
  3. os.Rename(dir, dir+".away").
  4. Add a second entry: the process panics with open <dir>/.state/treeState.lock: no such file or directory.

Expected: the lock error is returned, so doFlush hands it to every pending Add future, as publishCheckpoint and garbageCollect already do for their own locks. A failed unlock() could be logged rather than panicking. The appender re-reads its tree state each batch, so appends succeed again once the volume is back.

Patch we carry against v1.0.4 (sequenceBatch and appender.initialise; the MigrationStorage sites would take the same change):

 	a.s.mu.Lock()
 	unlock, err := a.s.lockFile(ctx, treeStateLock)
 	if err != nil {
-		panic(err)
+		if unlock != nil {
+			_ = unlock()
+		}
+		a.s.mu.Unlock()
+		return fmt.Errorf("lockFile(%s): %v", treeStateLock, err)
 	}
 	defer func() {
 		if err := unlock(); err != nil {
-			panic(err)
+			klog.Warningf("unlock(%s): %v", treeStateLock, err)
 		}
 		a.s.mu.Unlock()
 	}()

Happy to send this as a PR if that's useful.

Lingua principale
Go
Stelle
262
Fork
64
Merge medio
1g 6h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di transparency-dev/tessera

Tutte le issue di transparency-dev/tessera

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.