Skip to content

Commit

Permalink
support recover when background pipeline of mv finished unexpected
Browse files Browse the repository at this point in the history
  • Loading branch information
yl-lisen committed Jan 19, 2024
1 parent d7fe1d5 commit eea9655
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Storages/Streaming/StorageMaterializedView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern const int RESOURCE_NOT_INITED;
extern const int QUERY_WAS_CANCELLED;
extern const int MEMORY_LIMIT_EXCEEDED;
extern const int DIRECTORY_DOESNT_EXIST;
extern const int UNEXPECTED_ERROR_CODE;
}


Expand Down Expand Up @@ -567,6 +568,16 @@ void StorageMaterializedView::executeBackgroundPipeline(BlockIO & io, ContextMut
executor.setCancelCallback(
[this] { return background_state.is_cancelled.load(); }, local_context->getSettingsRef().interactive_delay / 1000);
executor.execute();

/// If the pipeline is finished, we need check whether it's cancelled or not. If not, it's abnormal.
/// For exmaple:
/// A background query likes stream join table, and the table has no data, the background pipeline will be finished immediately.
/// In this case, we need throw a exception to notify users and retry it.
if (!((*io.process_list_entry)->isKilled() || background_state.is_cancelled.load()))
throw Exception(
ErrorCodes::UNEXPECTED_ERROR_CODE,
"The background pipeline for materialized view {} finished unexpectedly, it's abnormal.",
getStorageID().getFullTableName());
}

void StorageMaterializedView::read(
Expand Down

0 comments on commit eea9655

Please sign in to comment.