3636#include " yb/master/clone/clone_state_manager.h"
3737#include " yb/master/cluster_balance.h"
3838#include " yb/master/master.h"
39- #include " yb/master/ts_descriptor.h"
4039#include " yb/master/tablet_split_manager.h"
4140#include " yb/master/ts_manager.h"
4241#include " yb/master/xcluster/xcluster_manager_if.h"
5049#include " yb/util/status_log.h"
5150#include " yb/util/thread.h"
5251
52+ using namespace std ::literals;
53+
5354using std::shared_ptr;
5455using std::vector;
5556
@@ -68,6 +69,10 @@ DEFINE_RUNTIME_bool(sys_catalog_respect_affinity_task, true,
6869 " Whether the master sys catalog tablet respects cluster config preferred zones "
6970 " and sends step down requests to a preferred leader." );
7071
72+ DEFINE_RUNTIME_int32 (master_bg_task_long_operation_warning_ms, 5 * 1000 ,
73+ " Log warnings if the catalog manager background tasks (combined) take longer than this amount "
74+ " of time." );
75+
7176DEFINE_test_flag (bool , pause_catalog_manager_bg_loop_start, false ,
7277 " Pause the bg tasks thread at the beginning of the loop." );
7378
@@ -86,10 +91,9 @@ DECLARE_bool(TEST_echo_service_enabled);
8691DECLARE_bool (cdcsdk_enable_dynamic_table_addition_with_table_cleanup);
8792DECLARE_bool (ysql_enable_auto_analyze_infra);
8893
89- namespace yb {
90- namespace master {
94+ namespace yb ::master {
9195
92- typedef std::unordered_map<TableId, std::list<CDCStreamInfoPtr>> TableStreamIdsMap ;
96+ using TableStreamIdsMap = std::unordered_map<TableId, std::list<CDCStreamInfoPtr>>;
9397
9498CatalogManagerBgTasks::CatalogManagerBgTasks (Master* master)
9599 : closing_(false ),
@@ -187,6 +191,10 @@ void CatalogManagerBgTasks::ClearDeadTServerMetrics() const {
187191}
188192
189193void CatalogManagerBgTasks::RunOnceAsLeader (const LeaderEpoch& epoch) {
194+ LongOperationTracker long_operation_tracker (
195+ " CatalogManagerBgTasks::RunOnceAsLeader" ,
196+ FLAGS_master_bg_task_long_operation_warning_ms * 1ms);
197+
190198 ClearDeadTServerMetrics ();
191199
192200 if (FLAGS_TEST_echo_service_enabled) {
@@ -408,5 +416,4 @@ void CatalogManagerBgTasks::Run() {
408416 VLOG (1 ) << " Catalog manager background task thread shutting down" ;
409417}
410418
411- } // namespace master
412- } // namespace yb
419+ } // namespace yb::master
0 commit comments