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

Add last_exception_time to replication_queue #45457

Merged
merged 2 commits into from Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Storages/MergeTree/ReplicatedMergeMutateTaskBase.cpp
Expand Up @@ -91,6 +91,7 @@ bool ReplicatedMergeMutateTaskBase::executeStep()
auto & log_entry = selected_entry->log_entry;

log_entry->exception = saved_exception;
log_entry->last_exception_time = time(nullptr);

if (log_entry->type == ReplicatedMergeTreeLogEntryData::MUTATE_PART)
{
Expand Down
1 change: 1 addition & 0 deletions src/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h
Expand Up @@ -157,6 +157,7 @@ struct ReplicatedMergeTreeLogEntryData
/// Access under queue_mutex, see ReplicatedMergeTreeQueue.
size_t num_tries = 0; /// The number of attempts to perform the action (since the server started, including the running one).
std::exception_ptr exception; /// The last exception, in the case of an unsuccessful attempt to perform the action.
time_t last_exception_time = 0; /// The time at which the last exception occurred.
time_t last_attempt_time = 0; /// The time at which the last attempt was attempted to complete the action.
size_t num_postponed = 0; /// The number of times the action was postponed.
String postpone_reason; /// The reason why the action was postponed, if it was postponed.
Expand Down
1 change: 1 addition & 0 deletions src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp
Expand Up @@ -1691,6 +1691,7 @@ bool ReplicatedMergeTreeQueue::processEntry(
{
std::lock_guard lock(state_mutex);
entry->exception = saved_exception;
entry->last_exception_time = time(nullptr);
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Storages/System/StorageSystemReplicationQueue.cpp
Expand Up @@ -38,6 +38,7 @@ NamesAndTypesList StorageSystemReplicationQueue::getNamesAndTypes()
{ "is_currently_executing", std::make_shared<DataTypeUInt8>() },
{ "num_tries", std::make_shared<DataTypeUInt32>() },
{ "last_exception", std::make_shared<DataTypeString>() },
{ "last_exception_time", std::make_shared<DataTypeDateTime>() },
{ "last_attempt_time", std::make_shared<DataTypeDateTime>() },
{ "num_postponed", std::make_shared<DataTypeUInt32>() },
{ "postpone_reason", std::make_shared<DataTypeString>() },
Expand Down Expand Up @@ -141,7 +142,8 @@ void StorageSystemReplicationQueue::fillData(MutableColumns & res_columns, Conte
res_columns[col_num++]->insert(entry.detach);
res_columns[col_num++]->insert(entry.currently_executing);
res_columns[col_num++]->insert(entry.num_tries);
res_columns[col_num++]->insert(entry.exception ? getExceptionMessage(entry.exception, false) : "");
res_columns[col_num++]->insert(entry.exception ? getExceptionMessage(entry.exception, true) : "");
res_columns[col_num++]->insert(UInt64(entry.last_exception_time));
res_columns[col_num++]->insert(UInt64(entry.last_attempt_time));
res_columns[col_num++]->insert(entry.num_postponed);
res_columns[col_num++]->insert(entry.postpone_reason);
Expand Down