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(transfer): rebuild pool on transient drop in batch transfer

Melody Ruch781bb46d3ad6
diff --git a/crates/dbx-core/src/transfer.rs b/crates/dbx-core/src/transfer.rs
index 4a2e5a5935..2db556ea5f 100644
--- a/crates/dbx-core/src/transfer.rs
+++ b/crates/dbx-core/src/transfer.rs
@@ -5148,6 +5148,33 @@ async fn execute_on_pool_with_options(
PoolErrorAction::Keep => return result,
PoolErrorAction::Discard => {
state.remove_pool_by_key(&current_pool_key).await;
+ // `WriteNoReplay` deliberately downgrades a recoverable connection
+ // error to `Discard` here so this specific write is never replayed
+ // (its outcome on the server is unknown). But leaving the pool
+ // torn down does not just affect this one statement: a bulk
+ // multi-table transfer keeps reusing this same `pool_key` for
+ // every remaining table, so once one table hits a transient
+ // connection drop (a momentary "too many connections"/"connection
+ // closed" from the target server under load), every later table
+ // immediately fails too with "Connection not found" / "Pool not
+ // found" -- turning one blip into a cascade for the rest of the
+ // run. Re-establish a fresh pool under the same key so the next
+ // caller isn't handed a known-dead connection; this never retries
+ // the failed statement above, only prepares the pool for
+ // whichever statement runs next.
+ if pool_error_action(db_type, error) == PoolErrorAction::ReconnectAndRetry {
+ if let Some(connection_id) = connection_id.as_deref() {
+ let catalog = catalog_from_pool_key(&current_pool_key).map(str::to_string);
+ let _ = state
+ .reconnect_pool_for_session_with_catalog(
+ connection_id,
+ database.as_deref(),
+ catalog.as_deref(),
+ client_session_id.as_deref(),
+ )
+ .await;
+ }
+ }
return result;
}
PoolErrorAction::ReconnectAndRetry if attempt == 0 => {