fix(plugins): terminate Windows sidecar process trees
This commit is contained in:
1 parent
c13af204dd
commit
88c006ee37
15 files changed
+656
-106
No files matched your search
@@ -149,7 +149,7 @@ async fn run() -> Result<(), String> {
|
||||
}
|
||||
|
||||
handle.disconnect().await?;
|
||||
host.stop_all().await;
|
||||
host.stop_all().await?;
|
||||
installer.uninstall(PLUGIN_ID)?;
|
||||
if !PluginRegistry::new_with_app_version(store.path().to_path_buf(), APP_VERSION).list_installed()?.is_empty() {
|
||||
return Err("Plugin store is not empty after uninstall".to_string());
|
||||
|
||||
@@ -305,7 +305,7 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(plan, "TABLE ACCESS FULL DUAL");
|
||||
session.shutdown().await;
|
||||
session.shutdown().await.unwrap();
|
||||
drop(state);
|
||||
std::fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ async fn embedded_h2_jdbc_failed_connect_cancel_drop_and_last_close_are_isolated
|
||||
panic!()
|
||||
};
|
||||
drop(dropped);
|
||||
good.shutdown().await;
|
||||
good.shutdown().await.unwrap();
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while good.pid().await.is_some() {
|
||||
tokio::task::yield_now().await;
|
||||
@@ -176,7 +176,7 @@ async fn embedded_h2_jdbc_failed_connect_cancel_drop_and_last_close_are_isolated
|
||||
panic!()
|
||||
};
|
||||
assert_ne!(reopened.pid().await, pid);
|
||||
reopened.shutdown().await;
|
||||
reopened.shutdown().await.unwrap();
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
@@ -201,8 +201,8 @@ async fn embedded_h2_jdbc_keeps_remote_memory_and_unrelated_drivers_dedicated()
|
||||
};
|
||||
assert_ne!(first.pid().await, second.pid().await);
|
||||
assert_eq!(identity(&first).await["session"], "legacy");
|
||||
first.shutdown().await;
|
||||
second.shutdown().await;
|
||||
first.shutdown().await.unwrap();
|
||||
second.shutdown().await.unwrap();
|
||||
}
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
@@ -268,9 +268,9 @@ async fn embedded_h2_jdbc_rejects_old_plugins_and_preserves_selected_driver_runt
|
||||
panic!()
|
||||
};
|
||||
assert_ne!(first.pid().await, different.pid().await);
|
||||
different.shutdown().await;
|
||||
first.shutdown().await;
|
||||
second.shutdown().await;
|
||||
different.shutdown().await.unwrap();
|
||||
first.shutdown().await.unwrap();
|
||||
second.shutdown().await.unwrap();
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
@@ -293,7 +293,7 @@ async fn embedded_h2_jdbc_last_owner_close_can_race_a_new_session() {
|
||||
let PoolKind::ExternalDriver { session: replacement, .. } = replacement.unwrap() else { panic!() };
|
||||
assert!(replacement.is_available(), "cycle {cycle_index}");
|
||||
identity(&replacement).await;
|
||||
replacement.shutdown().await;
|
||||
replacement.shutdown().await.unwrap();
|
||||
assert!(replacement.pid().await.is_none());
|
||||
}
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
@@ -332,7 +332,7 @@ async fn embedded_h2_jdbc_cancelled_open_releases_its_member_and_server_state()
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
survivor.shutdown().await;
|
||||
survivor.shutdown().await.unwrap();
|
||||
assert!(survivor.pid().await.is_none());
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
@@ -366,9 +366,11 @@ async fn embedded_h2_jdbc_replaces_dead_runtime_with_sibling_handles_still_alive
|
||||
};
|
||||
assert_ne!(replacement.pid().await, original_pid);
|
||||
assert!(replacement.pid().await.is_some());
|
||||
tokio::join!(first.shutdown(), sibling.shutdown());
|
||||
let (first_closed, sibling_closed) = tokio::join!(first.shutdown(), sibling.shutdown());
|
||||
first_closed.unwrap();
|
||||
sibling_closed.unwrap();
|
||||
identity(&replacement).await;
|
||||
replacement.shutdown().await;
|
||||
replacement.shutdown().await.unwrap();
|
||||
assert!(replacement.pid().await.is_none());
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
@@ -392,7 +394,7 @@ async fn embedded_h2_jdbc_timeout_and_interrupted_shutdown_finish_session_cleanu
|
||||
.unwrap_err();
|
||||
assert!(error.contains("timed out"));
|
||||
assert!(!timed.is_available());
|
||||
timed.shutdown().await;
|
||||
timed.shutdown().await.unwrap();
|
||||
identity(&survivor).await;
|
||||
let mut delayed = config.clone();
|
||||
delayed.username = "delay-close".into();
|
||||
@@ -402,7 +404,7 @@ async fn embedded_h2_jdbc_timeout_and_interrupted_shutdown_finish_session_cleanu
|
||||
};
|
||||
let close_session = closing.clone();
|
||||
let close = tokio::spawn(async move {
|
||||
close_session.shutdown().await;
|
||||
close_session.shutdown().await.unwrap();
|
||||
});
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while closing.is_available() {
|
||||
@@ -414,7 +416,7 @@ async fn embedded_h2_jdbc_timeout_and_interrupted_shutdown_finish_session_cleanu
|
||||
close.abort();
|
||||
assert!(close.await.unwrap_err().is_cancelled());
|
||||
identity(&survivor).await;
|
||||
survivor.shutdown().await;
|
||||
survivor.shutdown().await.unwrap();
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
while survivor.pid().await.is_some() {
|
||||
tokio::task::yield_now().await;
|
||||
@@ -422,7 +424,7 @@ async fn embedded_h2_jdbc_timeout_and_interrupted_shutdown_finish_session_cleanu
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
closing.shutdown().await;
|
||||
closing.shutdown().await.unwrap();
|
||||
state.shutdown(Duration::from_secs(5)).await;
|
||||
std::fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
@@ -1871,7 +1871,9 @@ impl AppState {
|
||||
Some(external_driver_connect_timeout(config)),
|
||||
)
|
||||
.await;
|
||||
session.shutdown().await;
|
||||
if let Err(error) = session.shutdown().await {
|
||||
log::warn!("Failed to stop the plugin runtime after testing connection '{}': {error}", config.name);
|
||||
}
|
||||
return result.map(|response| {
|
||||
ConnectionTestResult::success("Connection successful")
|
||||
.with_database_info(database_info_from_protocol_value(&response))
|
||||
@@ -1916,7 +1918,12 @@ impl AppState {
|
||||
session,
|
||||
}),
|
||||
Err(error) => {
|
||||
session.shutdown().await;
|
||||
if let Err(shutdown_error) = session.shutdown().await {
|
||||
log::warn!(
|
||||
"Failed to stop the plugin runtime after failing to connect '{}': {shutdown_error}",
|
||||
config.name
|
||||
);
|
||||
}
|
||||
Err(error)
|
||||
}
|
||||
}
|
||||
@@ -2429,7 +2436,7 @@ impl AppState {
|
||||
|
||||
let shutdown = async {
|
||||
let routing = self.pool_routing_control();
|
||||
tokio::join!(
|
||||
let (_, _, _, _, _, _, plugin_shutdown) = tokio::join!(
|
||||
self.task_supervisor.shutdown(deadline),
|
||||
routing.close_removed(removed_pools),
|
||||
self.tunnels.stop_all_tunnels(),
|
||||
@@ -2438,6 +2445,9 @@ impl AppState {
|
||||
self.agent_manager.stop_daemons(),
|
||||
self.plugin_host.stop_all(),
|
||||
);
|
||||
if let Err(error) = plugin_shutdown {
|
||||
log::warn!("Failed to stop plugin runtimes during shutdown: {error}");
|
||||
}
|
||||
};
|
||||
if tokio::time::timeout(deadline, shutdown).await.is_err() {
|
||||
log::warn!("Timed out shutting down DBX runtime resources after {}ms", deadline.as_millis());
|
||||
@@ -6847,7 +6857,7 @@ async fn close_pool_kind(pool: PoolKind) -> Result<(), String> {
|
||||
client.disconnect().await?;
|
||||
}
|
||||
PoolKind::ExternalDriver { session, .. } => {
|
||||
session.shutdown().await;
|
||||
session.shutdown().await?;
|
||||
}
|
||||
PoolKind::PluginConnection(handle) => {
|
||||
if let Err(error) = handle.disconnect().await {
|
||||
|
||||
@@ -10194,7 +10194,7 @@ for line in sys.stdin:
|
||||
assert_eq!(cells.len(), 1);
|
||||
assert_eq!(std::fs::read_to_string(&calls).unwrap().lines().count(), 4);
|
||||
|
||||
session.shutdown().await;
|
||||
session.shutdown().await.unwrap();
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
@@ -10379,7 +10379,7 @@ for line in sys.stdin:
|
||||
assert_eq!(result.rows, vec![vec![serde_json::json!(42)]]);
|
||||
assert_eq!(std::fs::read_to_string(&calls).unwrap(), "executeQueryPage\nexecuteQuery\n");
|
||||
|
||||
session.shutdown().await;
|
||||
session.shutdown().await.unwrap();
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
@@ -10443,7 +10443,7 @@ for line in sys.stdin:
|
||||
assert_eq!(error, "Incorrect syntax near SELECT");
|
||||
assert_eq!(std::fs::read_to_string(&calls).unwrap(), "request\n");
|
||||
|
||||
session.shutdown().await;
|
||||
session.shutdown().await.unwrap();
|
||||
let _ = std::fs::remove_dir_all(dir);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user