Title: Consider lazy durable entity state serialization semantics · Issue #234 · microsoft/durabletask-python · GitHub
Open Graph Title: Consider lazy durable entity state serialization semantics · Issue #234 · microsoft/durabletask-python
X Title: Consider lazy durable entity state serialization semantics · Issue #234 · microsoft/durabletask-python
Description: 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 ...
Open Graph Description: 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 a...
X Description: 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 a...
Opengraph URL: https://github.com/microsoft/durabletask-python/issues/234
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consider lazy durable entity state serialization semantics","articleBody":"## Summary\n\nDurable 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.\n\n```python\nstate = Point(1)\nself.set_state(state)\nstate.value = 99\n```\n\nThe persisted state is `Point(1)`, not `Point(99)`.\n\nThis 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()`.\n\n## Scope\n\nThe 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`.\n\n## Current rationale\n\nEager serialization was introduced intentionally to:\n\n- surface serialization errors inside the operation that called `set_state()`;\n- preserve per-operation rollback behavior in an entity batch;\n- retain the original serialized wire payload when state is unmodified; and\n- prevent mutations to values returned by `get_state()` from implicitly changing persisted state without a corresponding `set_state()`.\n\n## Design question\n\nShould `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?\n\nIf so, the design needs to define:\n\n- whether `get_state()` after `set_state()` returns the same pending live object or a reconstructed copy;\n- where serialization occurs so serialization failures still fail and roll back the current operation;\n- behavior across multiple operations in one entity batch;\n- compatibility implications of changing `set_state()` from snapshot-at-call semantics to retain-reference-until-commit semantics; and\n- consistency with Durable Entity semantics in other language SDKs.\n\n## Suggested investigation\n\n- Compare mutation semantics with other Durable Entity SDKs.\n- Prototype deferred serialization at the operation commit boundary.\n- Add tests for post-`set_state()` mutation, serialization failure, rollback, deletion, unmodified wire payloads, and multiple operations in one batch.\n- Document the current requirement to perform mutations before the final `set_state()` call unless the behavior changes.","author":{"url":"https://github.com/andystaples","@type":"Person","name":"andystaples"},"datePublished":"2026-07-29T15:50:29Z","url":"https://github.com/microsoft/durabletask-python/issues/234"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0e2bf3f9-5dba-be6b-49e9-6070a4b31b72 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E286:A9E5B:679F7:8FA1F:6AFE1E8D |
| html-safe-nonce | b104b2e5fba923d71d863f542c67e86e27c6524eb90c888d2e24a4e86fde982d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjg2OkE5RTVCOjY3OUY3OjhGQTFGOjZBRkUxRThEIiwidmlzaXRvcl9pZCI6IjM4MTM1MDY0NjMyNTUzNzE0MDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f374578d4b181637ce10c3a15fb3941fb5b6f929832f9f18b768a79d52eb7933 |
| hovercard-subject-tag | issue:5011148610 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/durabletask-python/234/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bdefbe2308f586c7e5b567805564a39ba9c4bbe8d8bcf895d5d4cdef45f49b62/microsoft/durabletask-python/issues/234 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bdefbe2308f586c7e5b567805564a39ba9c4bbe8d8bcf895d5d4cdef45f49b62/microsoft/durabletask-python/issues/234 |
| og:image:alt | 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 a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | andystaples |
| hostname | github.com |
| expected-hostname | github.com |
| None | d0525ab1464526bf4532a5551aa348cf100dff75ef808a96fc67a08b1d946aa9 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/durabletask-python git https://github.com/microsoft/durabletask-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 627664515 |
| octolytics-dimension-repository_nwo | microsoft/durabletask-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627664515 |
| octolytics-dimension-repository_network_root_nwo | microsoft/durabletask-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fef3993a71fa20f7be8e167132fbf9619bc66e12 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width