Skip to content

Commit

Permalink
make StorageNotFound Error recoverable in transient table
Browse files Browse the repository at this point in the history
  • Loading branch information
dantengsky committed Jun 14, 2022
1 parent 4f51d4c commit 197cbcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion query/src/catalogs/default/mutable_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Catalog for MutableCatalog {
async fn create_database(&self, req: CreateDatabaseReq) -> Result<CreateDatabaseReply> {
// Create database.
let res = self.ctx.meta.create_database(req.clone()).await?;
tracing::error!(
tracing::info!(
"db name: {}, engine: {}",
&req.name_ident.db_name,
&req.meta.engine
Expand Down
13 changes: 9 additions & 4 deletions query/src/storages/fuse/operations/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl FuseTable {
.with_max_elapsed_time(Some(max_elapsed))
.build();

let transient = self.transient();
let catalog_name = catalog_name.as_ref();
loop {
match tbl
Expand All @@ -97,7 +98,7 @@ impl FuseTable {
{
Ok(_) => {
break {
if self.transient() {
if transient {
// Removes historical data, if table is transient
tracing::warn!(
"transient table detected, purging historical data. ({})",
Expand All @@ -118,7 +119,9 @@ impl FuseTable {
Ok(())
};
}
Err(e) if self::utils::is_error_recoverable(&e) => match backoff.next_backoff() {
Err(e) if self::utils::is_error_recoverable(&e, transient) => match backoff
.next_backoff()
{
Some(d) => {
let name = tbl.table_info.name.clone();
tracing::warn!(
Expand Down Expand Up @@ -373,8 +376,10 @@ mod utils {
}

#[inline]
pub fn is_error_recoverable(e: &ErrorCode) -> bool {
e.code() == ErrorCode::table_version_mismatched_code()
pub fn is_error_recoverable(e: &ErrorCode, is_table_transient: bool) -> bool {
let code = e.code();
code == ErrorCode::table_version_mismatched_code()
|| (is_table_transient && code == ErrorCode::storage_not_found_code())
}

// check if there are any fuse table legacy options
Expand Down

0 comments on commit 197cbcf

Please sign in to comment.