microsoft / microsoft/durabletask-python

Consider lazy durable entity state serialization semantics

Aperta
#234 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
40
Fork
33
Merge medio
2g 2h
PR unite (30g)
6

Descrizione

Summary

Durable entity state is currently serialized eagerly when set_state() is called. This snapshots the value immediately, so mutations made to the same Python object after set_state() do not affect the state eventually persisted at the end of the operation.

state = Point(1)
self.set_state(state)
state.value = 99

The persisted state is Point(1), not Point(99).

This may surprise Python users who expect ordinary reference semantics and could introduce subtle bugs when entity code mutates an object after passing it to set_state().

Scope

The behavior is implemented in the core durabletask entity StateShim, so it affects core durabletask entities and providers built on it, including durabletask-azuremanaged and azure-functions-durable.

Current rationale

Eager serialization was introduced intentionally to:

  • surface serialization errors inside the operation that called set_state();
  • preserve per-operation rollback behavior in an entity batch;
  • retain the original serialized wire payload when state is unmodified; and
  • prevent mutations to values returned by get_state() from implicitly changing persisted state without a corresponding set_state().

Design question

Should set_state() retain the live value and defer serialization until successful operation completion, so mutations made after set_state() but before the operation returns are persisted?

If so, the design needs to define:

  • whether get_state() after set_state() returns the same pending live object or a reconstructed copy;
  • where serialization occurs so serialization failures still fail and roll back the current operation;
  • behavior across multiple operations in one entity batch;
  • compatibility implications of changing set_state() from snapshot-at-call semantics to retain-reference-until-commit semantics; and
  • consistency with Durable Entity semantics in other language SDKs.

Suggested investigation

  • Compare mutation semantics with other Durable Entity SDKs.
  • Prototype deferred serialization at the operation commit boundary.
  • Add tests for post-set_state() mutation, serialization failure, rollback, deletion, unmodified wire payloads, and multiple operations in one batch.
  • Document the current requirement to perform mutations before the final set_state() call unless the behavior changes.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia con l'entità Durable Task principale StateShim e traccia il modo in cui set_state(), get_state(), il completamento delle operazioni, il rollback e l'eliminazione gestiscono attualmente lo stato serializzato. Confronta la semantica delle mutazioni con quella di altri Durable Entity SDKs prima di decidere se la serializzazione differita sia appropriata. Aggiungi la copertura per la mutazione successiva a set_state, gli errori di serializzazione, il rollback, l'eliminazione, le wire payload invariate e più operazioni in un unico batch.

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

Valutazione

Stack tecnologico
python
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.