Add cancel reason CANCELLED_BY_ERROR.

This commit is contained in:
Vitaly Baranov 2024-12-12 02:10:41 +01:00
parent 78a7e0b840
commit 29bf43eaf2
3 changed files with 13 additions and 6 deletions

View File

@ -21,6 +21,8 @@ namespace ErrorCodes
{
extern const int FAILED_TO_SYNC_BACKUP_OR_RESTORE;
extern const int LOGICAL_ERROR;
extern const int QUERY_WAS_CANCELLED;
extern const int QUERY_WAS_CANCELLED_BY_CLIENT;
}
namespace
@ -692,7 +694,12 @@ void BackupCoordinationStageSync::cancelQueryIfError()
if (!exception)
return;
process_list_element->cancelQuery(CancelReason::CANCELLED_BY_USER, exception);
auto code = getExceptionErrorCode(exception);
auto cancel_reason = ((code == ErrorCodes::QUERY_WAS_CANCELLED) || (code == ErrorCodes::QUERY_WAS_CANCELLED_BY_CLIENT))
? CancelReason::CANCELLED_BY_USER
: CancelReason::CANCELLED_BY_ERROR;
process_list_element->cancelQuery(cancel_reason, exception);
state_changed.notify_all();
}
@ -747,7 +754,7 @@ void BackupCoordinationStageSync::cancelQueryIfDisconnectedTooLong()
/// we don't want the watching thread to try waiting here for retries or a reconnection).
/// Also we don't set the `state.host_with_error` field here because `state.host_with_error` can only be set
/// AFTER creating the 'error' node (see the comment for `State`).
process_list_element->cancelQuery(CancelReason::CANCELLED_BY_USER, exception);
process_list_element->cancelQuery(CancelReason::CANCELLED_BY_ERROR, exception);
state_changed.notify_all();
}

View File

@ -464,12 +464,11 @@ CancellationCode QueryStatus::cancelQuery(CancelReason reason, std::exception_pt
if (is_killed)
return CancellationCode::CancelSent;
LOG_TRACE(getLogger("ProcessList"), "Cancelling the query (reason: {})", reason);
is_killed = true;
if (!cancellation_exception)
cancellation_exception = exception;
cancel_reason = reason;
cancellation_exception = exception;
}
std::vector<ExecutorHolderPtr> executors_snapshot;

View File

@ -48,6 +48,7 @@ enum CancelReason
UNDEFINED,
TIMEOUT,
CANCELLED_BY_USER,
CANCELLED_BY_ERROR,
};
/** Information of process list element.