From e43f3fc02c18a609d5d723bf4862da271bc3a74f Mon Sep 17 00:00:00 2001 From: WiseDev <83840010+wisedevik@users.noreply.github.com> Date: Sun, 23 Aug 2026 09:42:44 +0300 Subject: [PATCH] unwind panics instead of aborting the process a panic in a session task now kills that connection, tokio catches it and the accept loop carries on. with abort it took the whole server down. the data table RwLock is std so it poisons on panic, and every lookup went through expect(). one panic would have bricked every later table read, which is worse than the abort was. it reads the inner value now, the table is read only once installed. --- Cargo.toml | 1 - crates/logic/src/data/logic_data_tables.rs | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c3f337b..c992d8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,5 +37,4 @@ syn = { version = "2", features = ["full", "extra-traits"] } opt-level = 3 lto = "thin" codegen-units = 1 -panic = "abort" strip = true diff --git a/crates/logic/src/data/logic_data_tables.rs b/crates/logic/src/data/logic_data_tables.rs index 2d620cd..5f53332 100644 --- a/crates/logic/src/data/logic_data_tables.rs +++ b/crates/logic/src/data/logic_data_tables.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; use std::path::Path; -use std::sync::{Arc, OnceLock, RwLock}; +use std::sync::{Arc, OnceLock, PoisonError, RwLock}; use titan::{CsvError, CsvReader, GlobalId}; use crate::data::logic_data::LogicData; use crate::data::logic_data_table::LogicDataTable; @@ -110,11 +110,15 @@ impl LogicDataTables { Self::default() } pub fn install(tables: Arc) -> bool { - let mut slot = INSTANCE.write().expect("data table lock poisoned"); + let mut slot = INSTANCE.write().unwrap_or_else(PoisonError::into_inner); slot.replace(tables).is_none() } pub fn instance() -> Arc { - match INSTANCE.read().expect("data table lock poisoned").as_ref() { + match INSTANCE + .read() + .unwrap_or_else(PoisonError::into_inner) + .as_ref() + { Some(tables) => Arc::clone(tables), None => Arc::clone(EMPTY.get_or_init(|| Arc::new(LogicDataTables::empty()))), } @@ -122,7 +126,7 @@ impl LogicDataTables { pub fn is_installed() -> bool { INSTANCE .read() - .expect("data table lock poisoned") + .unwrap_or_else(PoisonError::into_inner) .as_ref() .map(|tables| tables.is_loaded()) .unwrap_or(false)