Remove a session from the registry
(&self, session_id: &str)
| 142 | |
| 143 | /// Remove a session from the registry |
| 144 | pub fn remove_session(&self, session_id: &str) -> Result<(), String> { |
| 145 | let partition_idx = self.partition_index(session_id); |
| 146 | let mut partition = self.sessions[partition_idx] |
| 147 | .write() |
| 148 | .map_err(|_| "Failed to acquire partition write lock")?; |
| 149 | |
| 150 | if let Some(session_arc) = partition.remove(session_id) { |
| 151 | // Mark session as inactive |
| 152 | if let Ok(mut session) = session_arc.write() { |
| 153 | session.deactivate(); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | // Release partition lock before catalog persistence |
| 158 | drop(partition); |
| 159 | |
| 160 | // Persist catalogs when session is removed to ensure data is saved |
| 161 | if let Ok(catalog_manager) = self.catalog_manager.write() { |
| 162 | let persist_result = |
| 163 | SESSION_RUNTIME.with(|rt| rt.block_on(catalog_manager.persist_all())); |
| 164 | if let Err(e) = persist_result { |
| 165 | log::warn!("Failed to persist catalogs during session removal: {}", e); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | Ok(()) |
| 170 | } |
| 171 | |
| 172 | /// Get all active session IDs |
| 173 | pub fn get_active_session_ids(&self) -> Vec<String> { |
no test coverage detected