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

cluster: registerEntity does not reopen the storage read, so messages read before registration wait for entityMessagePollInterval

Aperta
#9,717 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start in packages/effect/src/cluster/Sharding.ts at the registerEntity logic around lines 1928-1937, then trace how storageReadLatch is opened by the poll fiber and how reads reset addresses for unregistered entity types around lines 860-864. Reproduce with persisted messages and no new client message; done means registration triggers an immediate storage reread and the pending handler runs without waiting for entityMessagePollInterval.

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

Descrizione

What happens

At boot, Sharding starts reading persisted messages as soon as it is built. An entity can only register after that, because registerEntity needs Sharding. When a read finds a message for an entity type that is not registered yet, Sharding resets the address and drops the message from that read ("reset address in the case that the entity is slow to register").

registerEntity then sets the entity manager inside withStorageReadLock, but it does not open storageReadLatch. With no new client message, nothing opens the latch until the poll fiber does, after entityMessagePollInterval (10 s by default). So every persisted message for that entity waits up to 10 s after a restart.

Where (packages/effect/src/cluster/Sharding.ts on main; same shape in the published 4.0.5)
  • the read skips an unregistered type: lines 860-864 (MutableHashSet.add(resetAddresses, address));
  • with no client message and no full batch, only the poll fiber opens the latch: lines 1071-1076;
  • registerEntity sets the manager and opens only the per-type latch: lines 1928-1937.
Reproduction
  1. A SqlMessageStorage-backed SingleRunner with a persisted entity message whose handler has not run (for example, the process was killed mid-handler).
  2. Restart. Build the runner, then register the entity in a later layer.
  3. Send no new message. The handler runs about entityMessagePollInterval after boot, not at registration.

In our app (gent), a resumed turn took 10.26 s with the default interval and 0.24 s after we call sharding.pollStorage once after registerEntity. With the interval set to one hour, the message did not run within a 10 s test window.

Suggested fix

Open storageReadLatch after entityManagers.set(...) in registerEntity (when the shard set is already acquired), so messages reset during the registration window are read again at once.

Workaround

Call Sharding.pollStorage after each registerEntity at the composition root.

Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
10h 7m
PR unite (30g)
808

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.