1b76cfff83
A failed flush at on_session_switch() restored the pending buffer and then cleared it on the next line, so an unavailable service at the switch boundary still lost every pending turn. Pending turns now carry their own session_id; _write_turns() batches per session, so a later retry (next turn, session end, shutdown) writes old-session turns under the old session's custom_id even after the switch. Addresses review on #109359.