You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address P1 review feedback on Modal snapshot rollout
Two fixes flagged by review on #1528:
1. Gateway backward compatibility during the release transition.
The default Modal release flow promotes the existing frontier worker
to current without redeploying it. With this PR shipped, the new
worker exposes the `HouseholdWorker` class but the promoted current
worker still only exposes the pre-PR top-level
`handle_household_request` function. `call_worker_function` now tries
`modal.Cls.from_name(..., "HouseholdWorker")` first and falls back to
`modal.Function.from_name(..., "handle_household_request")` on
`modal.exception.NotFoundError`, so both shapes route correctly
during the one release cycle where both coexist. Added two gateway
unit tests covering the class path and the function-fallback path.
2. Reset live network state captured by the memory snapshot.
Memory snapshots preserve Python object state but not live TCP
sockets; the SQLAlchemy pool and the Cloud SQL Connector created at
snapshot time hold sockets that closed when Modal froze the
container. Add `@modal.enter(snap=False) reset_post_snapshot_state`
on `HouseholdWorker` to run on every snapshot-restored container
start: re-establish the credentials file in case `/tmp` was not
preserved, then call `analytics_setup.cleanup()` (drops the Cloud SQL
Connector singleton) and `db.engine.dispose()` (drops the SQLAlchemy
connection pool). Subsequent queries open fresh connections. Added a
unit test asserting the hook is declared on the class.
References:
- https://modal.com/docs/guide/memory-snapshot
- https://modal.com/blog/mem-snapshots
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments