Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

sandbox/storage: stale team-index SET entries accumulate when sandbox keys are lost without going through Remove()

Aperta Adatta ai principianti
#3,566 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
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
go, redis
Ambito
databases

Direzione di ricerca

Inizia in items.go, su ExpiredItems, e segui come vengono rimossi i membri orfani dell'indice di scadenza e come vengono formate le chiavi dell'indice del team. Verifica i test esistenti di sandbox/storage e aggiungi la copertura per una chiave sandbox assente; il lavoro è completato quando la pulizia degli elementi orfani rimuove sia il membro di scadenza globale sia la relativa voce nell'indice del team, senza influire sui sandbox attivi.

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

Descrizione

Summary

The per-team sandbox index (sandbox:storage:{teamID}:index, a Redis SET) accumulates stale entries that are never cleaned up when sandbox keys disappear outside the normal Remove() path.

Root cause

ExpiredItems() sweeps orphaned ZSET members (entries in sandbox:storage:global:expiration whose corresponding sandbox key is gone), but only removes the ZSET member — it does not remove the sandboxID from the team index SET:

// items.go — current behaviour
if raw == nil {
    staleMembers = append(staleMembers, ref.member)  // ZREM the ZSET member ✓
    orphanCount++
    continue  // team index entry is NOT cleaned ✗
}

No other code path cleans the team index for absent sandbox keys:

  • TeamItems / fetchSandboxBatch silently skip nil MGET results with a continue
  • The healer (healExpirationIndex) only fills missing ZSET members, never prunes the team index
  • Remove() / removeSandboxScript cleans both atomically, but only runs on the normal removal path

The team index SET therefore grows without bound whenever sandbox keys disappear externally — most commonly via Redis maxmemory key eviction or a Redis restart with incomplete persistence.

Observed impact

Teams with high sandbox churn (frequent create / pause / resume cycles) combined with Redis key eviction can accumulate thousands of stale SET members, inflating Redis memory and slowing TeamItems (SMEMBERS + MGET fan-out is proportional to SET size, including stale entries).

Trigger conditions

  • Redis maxmemory policy that can evict individual sandbox keys (allkeys-lru, allkeys-random, etc.)
  • Redis restart with RDB/AOF disabled or incomplete
  • Any path that deletes a sandbox key without calling sandboxStore.Remove()

Frequent autoPause / autoResume amplifies the issue by increasing per-team sandbox churn and Redis memory pressure, raising the probability of key eviction.

Fix

When ExpiredItems finds an orphaned ZSET member (MGET returned nil), also SREM the sandboxID from the team index. MGET already confirmed the sandbox key is absent, so we cannot unindex a live sandbox. A concurrent Add that races the SREM will SADD the sandboxID back immediately, so the worst outcome is a brief gap in TeamItems results for one eviction cycle.

Lingua principale
Go
Stelle
1.6k
Fork
438
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 e2b-dev/runtime

Tutte le issue di e2b-dev/runtime

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.