MCPcopy Create free account
hub / github.com/ByConity/ByConity / iterate

Method iterate

src/Databases/MySQL/MaterializedMySQLSyncThreadManager.cpp:682–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680}
681
682bool MaterializedMySQLSyncThreadManager::iterate()
683{
684 if (!initialized)
685 {
686 initialize();
687 initialized = true;
688 }
689
690 /// When materialized_tables_list is empty, reinit
691 if (materialized_tables_list.empty())
692 initialized = false;
693
694 /// Judge whether sync thread manager should stop according to settings & skip_sync_failed_tables/skipped_unsupported_tables
695 {
696 std::lock_guard lock(status_info_mutex);
697 if ((!materialized_mysql_ptr->getMaterializeMySQLSettings()->skip_sync_failed_tables && !sync_failed_tables.empty())
698 || (!materialized_mysql_ptr->getMaterializeMySQLSettings()->skip_unsupported_tables && !skipped_unsupported_tables.empty()))
699 {
700 stopSyncThreads();
701 threads_info.clear();
702 initialized = false;
703 setSyncType(MaterializedMySQLSyncType::ExceptionStopSync);
704 return true;
705 }
706 }
707 /// Make a copy of `threads_info` for each iteration to avoid hold the lock for a long time
708 /// while the DDL actions would change the `threads_info`
709 std::vector<SyncThreadScheduleInfoPtr> current_threads_info;
710 {
711 std::lock_guard lock(status_info_mutex);
712 for (auto & thread_info : threads_info)
713 {
714 std::lock_guard thread_lock(thread_info->mutex);
715 if (shouldSyncTable(thread_info->assigned_materialized_table, false, false))
716 current_threads_info.emplace_back(thread_info);
717 }
718 }
719
720 setSyncType(MaterializedMySQLSyncType::Syncing);
721 std::lock_guard resync_lock(resync_mutex);
722 for (auto & thread_info : current_threads_info)
723 {
724 std::lock_guard thread_lock(thread_info->mutex);
725 if (resync_tables.count(thread_info->assigned_materialized_table))
726 continue;
727
728 if (thread_info->worker_client)
729 checkStatusOfSyncThread(thread_info);
730
731 if (!thread_info->worker_client)
732 scheduleSyncThreadToWorker(thread_info);
733 }
734 return false;
735}
736
737void MaterializedMySQLSyncThreadManager::initialize()
738{

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.45
clearMethod · 0.45
emplace_backMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected