Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make error message of conflicting transactions more user-friendly #17307

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/query/catalog/src/catalog/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ use databend_common_meta_types::SeqV;
use databend_storages_common_session::SessionState;
use databend_storages_common_table_meta::table::OPT_KEY_TEMP_PREFIX;
use dyn_clone::DynClone;
use log::info;

use crate::database::Database;
use crate::table::Table;
Expand Down Expand Up @@ -388,16 +389,21 @@ pub trait Catalog: DynClone + Send + Sync + Debug {
&self,
req: UpdateMultiTableMetaReq,
) -> Result<UpdateTableMetaReply> {
self.retryable_update_multi_table_meta(req)
.await?
.map_err(|e| {
ErrorCode::TableVersionMismatched(format!(
"Fail to update table metas, conflict tables: {:?}",
e.iter()
.map(|(tid, seq, meta)| (tid, seq, &meta.engine))
.collect::<Vec<_>>()
))
})
let result = self.retryable_update_multi_table_meta(req).await?;
match result {
Ok(reply) => Ok(reply),
Err(failed_tables) => {
let err_msg = format!(
"Due to concurrent transactions, transaction commit failed. Conflicting table IDs: {:?}",
failed_tables.iter().map(|(tid, _, _)| tid).collect::<Vec<_>>()
);
info!(
"Due to concurrent transactions, transaction commit failed. Conflicting tables: {:?}",
failed_tables
);
Err(ErrorCode::TableVersionMismatched(err_msg))
}
}
}

// update stream metas, currently used by "copy into location form stream"
Expand Down
10 changes: 6 additions & 4 deletions src/query/sql/src/planner/binder/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,12 @@ pub async fn execute_commit_statement(ctx: Arc<dyn TableContext>) -> Result<()>
}
Err(e) => {
let err_msg = format!(
"COMMIT: Table versions mismatched in multi statement transaction, conflict tables: {:?}",
e.iter()
.map(|(tid, seq, meta)| (tid, seq, &meta.engine))
.collect::<Vec<_>>()
"Due to concurrent transactions, explicit transaction commit failed. Conflicting table IDs: {:?}",
e.iter().map(|(tid, _, _)| tid).collect::<Vec<_>>()
);
info!(
"Due to concurrent transactions, explicit transaction commit failed. Conflicting table IDs: {:?}",
e
);
return Err(ErrorCode::TableVersionMismatched(err_msg));
}
Expand Down
Loading