Merge pull request #46564 from AVMusorin/update-time-distribution-queue

Added `last_exception_time` column into distribution_queue table
This commit is contained in:
pufit 2023-02-22 10:43:35 -05:00 committed by GitHub
commit 8e7533fa57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 3 deletions

View File

@ -465,6 +465,7 @@ void StorageDistributedDirectoryMonitor::run()
tryLogCurrentException(getLoggerName().data()); tryLogCurrentException(getLoggerName().data());
status.last_exception = std::current_exception(); status.last_exception = std::current_exception();
status.last_exception_time = std::chrono::system_clock::now();
} }
} }
else else

View File

@ -58,6 +58,7 @@ public:
struct InternalStatus struct InternalStatus
{ {
std::exception_ptr last_exception; std::exception_ptr last_exception;
std::chrono::system_clock::time_point last_exception_time;
size_t error_count = 0; size_t error_count = 0;

View File

@ -101,6 +101,7 @@ NamesAndTypesList StorageSystemDistributionQueue::getNamesAndTypes()
{ "broken_data_files", std::make_shared<DataTypeUInt64>() }, { "broken_data_files", std::make_shared<DataTypeUInt64>() },
{ "broken_data_compressed_bytes", std::make_shared<DataTypeUInt64>() }, { "broken_data_compressed_bytes", std::make_shared<DataTypeUInt64>() },
{ "last_exception", std::make_shared<DataTypeString>() }, { "last_exception", std::make_shared<DataTypeString>() },
{ "last_exception_time", std::make_shared<DataTypeDateTime>() },
}; };
} }
@ -190,6 +191,7 @@ void StorageSystemDistributionQueue::fillData(MutableColumns & res_columns, Cont
res_columns[col_num++]->insert(getExceptionMessage(status.last_exception, false)); res_columns[col_num++]->insert(getExceptionMessage(status.last_exception, false));
else else
res_columns[col_num++]->insertDefault(); res_columns[col_num++]->insertDefault();
res_columns[col_num++]->insert(static_cast<UInt32>(std::chrono::system_clock::to_time_t(status.last_exception_time)));
} }
} }
} }

View File

@ -1,4 +1,4 @@
masked masked
3,"default:*@127%2E0%2E0%2E1:9000,default:*@127%2E0%2E0%2E2:9000" 3,"default:*@127%2E0%2E0%2E1:9000,default:*@127%2E0%2E0%2E2:9000","AUTHENTICATION_FAILED",1
no masking no masking
1,"default@localhost:9000" 1,"default@localhost:9000"

View File

@ -18,7 +18,7 @@ create table dist_01555 (key Int) Engine=Distributed(test_cluster_with_incorrect
insert into dist_01555 values (1)(2); insert into dist_01555 values (1)(2);
-- since test_cluster_with_incorrect_pw contains incorrect password ignore error -- since test_cluster_with_incorrect_pw contains incorrect password ignore error
system flush distributed dist_01555; -- { serverError 516; } system flush distributed dist_01555; -- { serverError 516; }
select length(splitByChar('*', data_path)), replaceRegexpOne(data_path, '^.*/([^/]*)/' , '\\1') from system.distribution_queue where database = currentDatabase() and table = 'dist_01555' format CSV; select length(splitByChar('*', data_path)), replaceRegexpOne(data_path, '^.*/([^/]*)/' , '\\1'), extract(last_exception, 'AUTHENTICATION_FAILED'), dateDiff('s', last_exception_time, now()) < 5 from system.distribution_queue where database = currentDatabase() and table = 'dist_01555' format CSV;
drop table dist_01555; drop table dist_01555;

View File

@ -229,7 +229,8 @@ CREATE TABLE system.distribution_queue
`data_compressed_bytes` UInt64, `data_compressed_bytes` UInt64,
`broken_data_files` UInt64, `broken_data_files` UInt64,
`broken_data_compressed_bytes` UInt64, `broken_data_compressed_bytes` UInt64,
`last_exception` String `last_exception` String,
`last_exception_time` DateTime
) )
ENGINE = SystemDistributionQueue ENGINE = SystemDistributionQueue
COMMENT 'SYSTEM TABLE is built on the fly.' COMMENT 'SYSTEM TABLE is built on the fly.'