Persist flow state and restore or recover it at startup
Categories
(Data Platform and Tools :: Glean: SDK, enhancement, P1)
Tracking
(Not tracked)
People
(Reporter: travis_, Assigned: travis_)
References
(Blocks 2 open bugs)
Details
Attachments
(1 external file)
Sessions resume across clean restarts, so active flow instances must too. Otherwise backgrounding the app and having it killed would end every flow with no outcome. Depends on Bug 2077136, the lifecycle bug, and the session-end bug.
Persistence:
- Store flow state in
INTERNAL_STORAGEwithLifetime::User, next tosession#*. For each instance:flow_name,flow_seq, owningsession_id, start time. Store the session-wide flow counter in the same write. - Write only when an instance opens or closes. Nothing is written on the recording path otherwise.
Clean restart (restore_session_state_from_storage()):
- Restore instances only if their
session_idmatches the session being restored. Discard the rest. - Restore the flow counter with them, or the resumed session will reuse sequence numbers and two instances will share an identity.
- Discard, without a
flow_end, any instance whose flow is no longer registered. - Restore instances of a disabled flow. Restoring is not opening, and the kill switch only applies to opening.
- Check
auto_close_timeoutwhile restoring, and close expired instances withreason: timeoutright away. - If the session is restored and later ends by timeout in
handle_client_active(), the restored instances are closed by the session-end hook as usual.
Dirty-flag restart (recover_session_on_dirty_flag()):
- For each persisted instance whose flow is still registered, record a
glean.flow_endwithreason: abnormaland the originalsession_idas an extra. Record it out-of-session, since the original session is not current, and before the recoverysession_end. Then clear flow state.
Session mode change at startup: when the persisted session is abandoned with session_end("abandoned"), treat its instances the same way as on a dirty-flag restart.
Opt-out: clear_metrics() already clears the stored state. Reset the in-memory flow state explicitly as well, and record no flow_end. See Bug 2077130 for the same problem with SessionManager.
Comment 1•20 days ago
|
||
(via GitHub webhook, authenticated as shared-secret)
| Assignee | ||
Updated•20 days ago
|
| Assignee | ||
Updated•6 days ago
|
Description
•