Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(schema): retry transient metadata pool miss

t8y284215a7e605f
diff --git a/crates/dbx-core/src/schema.rs b/crates/dbx-core/src/schema.rs
index 50bd29df68..2afc7ac40f 100644
--- a/crates/dbx-core/src/schema.rs
+++ b/crates/dbx-core/src/schema.rs
@@ -1177,9 +1177,9 @@ mod tests {
use super::db;
use super::{
clickhouse_metadata_database, deduplicate_column_infos, filter_mysql_system_databases_for_config,
- filter_table_infos, is_agent_postgres_metadata_fallback_config, mysql_table_metadata_catalog,
- normalize_information_schema_table_type, oracle_table_comment_from_query_result, oracle_table_comment_sql,
- presto_like_information_schema_tables_sql, presto_like_tables_from_query_result,
+ filter_table_infos, is_agent_postgres_metadata_fallback_config, is_retryable_metadata_error,
+ mysql_table_metadata_catalog, normalize_information_schema_table_type, oracle_table_comment_from_query_result,
+ oracle_table_comment_sql, presto_like_information_schema_tables_sql, presto_like_tables_from_query_result,
};
#[cfg(feature = "duckdb-bundled")]
use super::{
@@ -1257,6 +1257,14 @@ mod tests {
assert_eq!(mysql_table_metadata_catalog("app_db", "public"), "app_db");
}
+ #[test]
+ fn metadata_retry_recovers_missing_pool_only_as_transient_state() {
+ assert!(is_retryable_metadata_error("Pool not found"));
+ assert!(is_retryable_metadata_error("connection reset by peer"));
+ assert!(!is_retryable_metadata_error("Unknown column 'email' in 'field list'"));
+ assert!(!is_retryable_metadata_error("Access denied for user"));
+ }
+
fn test_table_info(name: &str) -> super::db::TableInfo {
super::db::TableInfo {
name: name.to_string(),
@@ -2175,7 +2183,7 @@ where
{
let result = operation().await;
match result {
- Err(error) if crate::query::is_connection_error(&error) => {
+ Err(error) if is_retryable_metadata_error(&error) => {
state.reconnect_pool(connection_id, database).await?;
operation().await
}
@@ -2183,6 +2191,10 @@ where
}
}
+fn is_retryable_metadata_error(error: &str) -> bool {
+ error == "Pool not found" || crate::query::is_connection_error(error)
+}
+
pub async fn get_columns_core(
state: &AppState,
connection_id: &str,