{"id":1356,"date":"2021-07-21T00:00:00","date_gmt":"2021-07-21T00:00:00","guid":{"rendered":"https:\/\/en.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/"},"modified":"2025-11-14T06:22:02","modified_gmt":"2025-11-14T14:22:02","slug":"tidb-operator-source-code-reading-3-component-control-loop","status":"publish","type":"post","link":"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/","title":{"rendered":"TiDB Operator Source Code Reading (III): The Component Control Loop"},"content":{"rendered":"<blockquote>\n<p><em>Previous articles in this series:<\/em><\/p>\n<ul>\n<li><em><a href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-1-overview\/\">TiDB Operator Source Code Reading (I): Overview<\/a><\/em><\/li>\n<li><em><a href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-2-operator-pattern\/\">TiDB Operator Source Code Reading (II): Operator Pattern<\/a><\/em><\/li>\n<\/ul>\n<\/blockquote>\n\n\n\n<p>In my <a href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-2-operator-pattern\/#controllers-internal-logic\">last article<\/a>, I introduced how we design and implement <code>tidb-controller-manager<\/code> and the controllers&#8217; internal logic and how each controller receives and handles changes. <strong>This time, I&#8217;ll describe how we implement the component controllers.<\/strong><\/p>\n\n\n\n<p>The <code>TidbCluster<\/code> controller manages the lifecycles of major components in TiDB. I&#8217;ll take <code>TidbCluster<\/code> as an example to introduce the design of the component control loop. <strong>You&#8217;ll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.<\/strong><\/p>\n\n\n\n<p>This article is only a general introduction to the processes and definitions. The specific application of each component will be covered in the next article. Now, let&#8217;s get started.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Call_the_component_control_loop\"><\/span>Call the component control loop<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In the section on the <a href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-2-operator-pattern\/#controllers-internal-logic\">controller&#8217;s internal logic<\/a>, I mentioned the <code>updateTidbCluster<\/code> function of the <code>TidbCluster<\/code> controller, which is located in <code>pkg\/controller\/tidbcluster\/tidb_cluster_control.go<\/code>. As the entrance of TiDB component lifecycle management, this function calls a sequence of lifecycle management functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>c.reclaimPolicyManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.orphanPodsCleaner.Clean(tc)<\/code><\/li>\n\n\n\n<li><code>c.discoveryManager.Reconcile(tc)<\/code><\/li>\n\n\n\n<li><code>c.ticdcMemberManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.tiflashMemberManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.pdMemberManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.tikvMemberManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.pumpMemberManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.tidbMemberManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.metaManager.Sync(tc)<\/code><\/li>\n\n\n\n<li><code>c.pvcCleaner.Clean(tc)<\/code><\/li>\n\n\n\n<li><code>c.pvcResizer.Resize(tc)<\/code><\/li>\n\n\n\n<li><code>c.tidbClusterStatusManager.Sync(tc)<\/code><\/li>\n<\/ul>\n\n\n\n<p>These functions are divided into two categories:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>The implementation of control loops for TiDB components<\/strong>, such as PD, TiDB, TiKV, TiFlash, TiCDC, Pump, and Discovery.<\/li>\n\n\n\n<li><strong>The management of Kubernetes resources used by TiDB components<\/strong> \uadf8\ub9ac\uace0 <strong>the lifecycle management of other components<\/strong>, such as maintaining PV&#8217;s reclaim policy, cleaning up orphan Pods, maintaining the meta information of Kubernetes resources, cleaning and <a href=\"https:\/\/www.pingcap.com\/ko\/solutions\/modernize-mysql-workloads\/\">scaling out<\/a> PVCs, and managing the status of the <code>TidbCluster<\/code> object.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"The_lifecycle_management_process_of_TiDB_components\"><\/span>The lifecycle management process of TiDB components<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The control loop code for TiDB&#8217;s major components is located in the directory <code>pkg\/manager\/member<\/code> and in files that end with <code>_member_manager.go<\/code>, such as <code>pd_member_manager.go<\/code>. These files reference other files that implement scaling and upgrade features, such as <code>_scaler.go<\/code> \uadf8\ub9ac\uace0 <code>_upgrader.go<\/code>.<\/p>\n\n\n\n<p>From the <code>_member_manager.go<\/code> files of components, we can identify the generic implementation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Sync Service\nif err := m.syncServiceForTidbCluster(tc); err != nil {\n    return err\n}\n\n\/\/ Sync Headless Service\nif err := m.syncHeadlessServiceForTidbCluster(tc); err != nil {\n    return err\n}\n\n\/\/ Sync StatefulSet\nreturn syncStatefulSetForTidbCluster(tc)\n\nfunc syncStatefulSetForTidbCluster(tc *v1alpha1.TidbCluster) error {\n    if err := m.syncTidbClusterStatus(tc, oldSet); err != nil {\n        klog.Errorf(\"failed to sync TidbCluster: &#91;%s\/%s]'s status, error: %v\", ns, tcName, err)\n    }\n\n    if tc.Spec.Paused {\n        klog.V(4).Infof(\"tidb cluster %s\/%s is paused, skip syncing for statefulset\", tc.GetNamespace(), tc.GetName())\n        return nil\n    }\n\n    cm, err := m.syncConfigMap(tc, oldSet)\n\n    newSet, err := getnewSetForTidbCluster(tc, cm)\n\n    if err := m.scaler.Scale(tc, oldSet, newSet); err != nil {\n        return err\n    }\n\n    if err := m.failover.Failover(tc); err != nil {\n        return err\n    }\n\n    if err := m.upgrader.Upgrade(tc, oldSet, newSet); err != nil {\n        return err\n    }\n\n    return UpdateStatefulSet(m.deps.StatefulSetControl, tc, newSet, oldSet)\n}\n<\/code><\/pre>\n\n\n\n<p>The above code performs two major tasks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sync Service: Creates or syncs the Service resources for TiDB components.<\/li>\n\n\n\n<li>Sync StatefulSet:\n<ul class=\"wp-block-list\">\n<li>Syncs the component status.<\/li>\n\n\n\n<li>Checks whether <code>TidbCluster<\/code> stops the synchronization.<\/li>\n\n\n\n<li>Syncs ConfigMap.<\/li>\n\n\n\n<li>Generates a new StatefulSet according to the configuration in <code>TidbCluster<\/code> and performs the related operations on the new StatefulSet, such as rolling update, <a href=\"https:\/\/www.pingcap.com\/ko\/solutions\/modernize-mysql-workloads\/\">scaling out<\/a>, scaling in, and failover.<\/li>\n\n\n\n<li>Creates or updates the StatefulSet.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>The component control loop repeatedly performs the tasks above to make sure the component stays up to date.<\/p>\n\n\n\n<p>The following sections introduce the specific jobs completed in the control loop.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sync Service<\/h3>\n\n\n\n<p>When component reconciliation starts, service reconciliation also kicks off. <strong>This process creates and syncs the Services used by the components<\/strong>, such as <code>cluster1-pd<\/code> \uadf8\ub9ac\uace0 <code>cluster1-pd-peer<\/code>.<\/p>\n\n\n\n<p>The control loop function calls the <code>getNewServiceForTidbCluster<\/code> function, which creates a new Service template according to the information recorded in the <code>TidbCluster<\/code> custom resource (CR). If the Service doesn&#8217;t exist, the control loop function creates a Service; if the Service exists, it compares the old Service Spec with the new one and determines whether to update the Service object.<\/p>\n\n\n\n<p>There are both Services and Headless Services to allow the components to be accessed by others.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the component doesn&#8217;t need to know which instance it is talking to, and if the component supports load-balancing, such as when TiKV and TiDB access Placement Driver (PD), the component uses a Service.<\/li>\n\n\n\n<li>If the component needs to know which Pod is providing service, it uses a Headless Service to communicate via <a href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/statefulset\/#stable-network-id\">Pod DNS<\/a>. For example, when TiKV starts, it exposes its Pod DNS as the advertise address so that other Pods can access TiKV via the Pod DNS.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Sync StatefulSet<\/h3>\n\n\n\n<p>After the Service is synced, the components are connected to the cluster network, so they can access the cluster and be accessed from within the cluster. The control loop enters the <code>syncStatefulSetForTidbCluster<\/code> function and starts reconciling the StatefulSet.<\/p>\n\n\n\n<p>The first step in reconciling the StatefulSet is to sync the component status by running the <code>syncTidbClusterStatus<\/code> function. Then, according to the status information, other operations will be carried out such as upgrade, scaling in, scaling out, and failover.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Sync the component status<\/h4>\n\n\n\n<p>One of TiDB Operator&#8217;s key operations is to sync the component status. The status information contains:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Kubernetes&#8217;s component information, including the number of replicas in the cluster, the update status, and the image version. TiDB Operator also checks whether the StatefulSet is in the update process.<\/li>\n\n\n\n<li>TiDB&#8217;s internal cluster information. TiDB Operator syncs the information from PD, including information about PD members, TiKV storage, and TiDB members. TiDB Operator also performs health checks on TiDB.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Check whether the TiDB cluster pauses the synchronization<\/h4>\n\n\n\n<p>After syncing the status, TiDB Operator determines whether the cluster stops the synchronization by checking <code>tc.Spec.Paused<\/code>. If the sync is paused, TiDB Operator skips all the following operations that updates the StatefulSet.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Sync ConfigMap<\/h4>\n\n\n\n<p>After syncing the status, the <code>syncConfigMap<\/code> function updates the ConfigMap, which contains the component&#8217;s configuration file and startup script.<\/p>\n\n\n\n<p>The configuration file is extracted from the <code>Config<\/code> item in <code>Spec<\/code> of the YAML file. TiDB Operator supports directly using TOML configuration (recommended) or transforming the configuration from YAML.<\/p>\n\n\n\n<p>The startup script contains the startup parameters required for the component and launches the component process using the parameters.<\/p>\n\n\n\n<p>When a component needs to obtain the startup parameters from TiDB Operator, the information processing is performed in the Discovery component. For example, when PD needs to use parameters to determine whether it should initialize a node or join a node, it uses wget to access Discovery and get the parameters. By obtaining parameters from the startup script, TiDB Operator avoids unexpected rolling updates while StatefulSet is being updated. This may impact online services.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Generate a new StatefulSet<\/h4>\n\n\n\n<p>The <code>getNewPDSetForTidbCluster<\/code> function obtains a new StatefulSet template, which contains the references of the newly generated Service and ConfigMap. The function uses the latest status and spec to generate other items, such as <code>env<\/code>, <code>container<\/code>, \uadf8\ub9ac\uace0 <code>volume<\/code>.<\/p>\n\n\n\n<p>This new StatefulSet then goes through three processes: rolling update, scaling, and failover. Finally, the <code>UpdateStatefulSet<\/code> function compares the existing StatefulSet and the new one and determines whether to update the existing one.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Rolling update<\/h5>\n\n\n\n<p>The <code>m.upgraded.Upgrade<\/code> function performs operations related to rolling update, mainly updating <code>UpgradeStrategy.Type<\/code> \uadf8\ub9ac\uace0 <code>UpgradeStrategy.Partition<\/code> in the StatefulSet.<\/p>\n\n\n\n<p>The rolling update operation is performed using the rolling update strategy in the StatefulSet. When the component is being reconciled, it sets the update strategy of the StatefulSet to rolling update. In Kubernetes, you can control the rolling update progress by configuring <code>UpgradeStrategy.Partition<\/code>. The StatefulSet only updates the Pods that are not updated before and whose ID is greater than or equal to the value of <code>UpgradeStrategy.Partition<\/code>. TiDB Operator uses this mechanism to ensure that each Pod is only rolling updated after it can provide service to the external application normally.<\/p>\n\n\n\n<p>When the cluster is not being updated or is just in the starting phase of update, the component reconciliation sets <code>UpgradeStrategy.Partition<\/code> to the largest Pod ID in the StatefulSet. This prevents any Pod from being updated. After the update starts, when a Pod is updated and provides service after restart, the Pod is deemed successfully upgraded. TiDB Operator then decrements the <code>UpgradeStrategy.Partition<\/code> value and updates the next Pod.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Scaling in and scaling out<\/h5>\n\n\n\n<p><code>m.scaler.Scale<\/code> scales components in and out. Its primary task is to update <code>Replicas<\/code> of components in the StatefulSet.<\/p>\n\n\n\n<p>The <code>m.scaler.Scale<\/code> function scales components one by one, one step at a time. It compares the number of <code>Replicas<\/code> for a component in <code>TidbCluster<\/code> CR (for example <code>tc.Spec.PD.Replicas<\/code>) and with the current <code>Replicas<\/code>. Based on that, it determines whether to scale out or scale in the component and performs the scaling operation on one replica. It then enters the next round of component reconciliation. Through multiple rounds of reconciliation, <code>m.scaler.Scale<\/code> completes all scaling requirements.<\/p>\n\n\n\n<p>During the scaling process, PD needs to transfer the Leader, and TiKV needs to delete stores. These operations use PD APIs. During reconciliation, the <code>m.scaler.Scale<\/code> function uses PD APIs to perform the operation and check whether the operation is successful. If so, it moves to the next scaling operation.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Failover<\/h5>\n\n\n\n<p>The <code>m.failover.Failover<\/code> function performs operations related to disaster recovery, including discovering failure, recording failure status, and recovering from failure.<\/p>\n\n\n\n<p>If you enable <code>AutoFailover<\/code> when you deploy TiDB Operator, TiDB Operator monitors the component failure status. When it finds one, TiDB Operator records the failure information to <code>FailureStores<\/code> \ub610\ub294 <code>FailureMembers<\/code>. Next, it starts a new component Pod to take over the workload of the failed Pod. After the failed Pod recovers, TiDB Operator modifies the number of replicas in the StatefulSet to scale in the new Pod.<\/p>\n\n\n\n<p>When TiDB Operator performs failover for TiKV and TiFlash, the newly-created Pod is not scaled in by default. You need to configure <code>spec.tikv.recoverFailover: true<\/code> to enable the auto scaling-in.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Update the existing StatefulSet<\/h4>\n\n\n\n<p>In the last phase, the new StatefulSet is created. The control loop now enters the <code>UpdateStatefulSet<\/code> function, which compares the new StatefulSet with the existing one. If the two StatefulSets are inconsistent, the function updates the existing StatefulSet.<\/p>\n\n\n\n<p>The function also checks whether there are StatefulSets that are not managed by TiDB Operator. Because earlier versions of TiDB Operator used Helm Chart to deploy TiDB, TiDB Operator needs to add dependency marks to these old StatefulSets and include them in the lifecycle management.<\/p>\n\n\n\n<p>After the operations above, the status of the <code>TidbCluster<\/code> CR is updated to the latest version. The related Service and ConfigMap is created. The new StatefulSet is generated, which performs rolling update, scaling, and failover. The component reconciliation rolls on, monitoring the component lifecycle and responding to lifecycle status change and user-specified change. The whole cluster runs normally.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other lifecycle management tasks<\/h3>\n\n\n\n<p>Apart from the reconciliation of major components in TiDB, other lifecycle management operations are performed by the following functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Discovery configures PD startup parameters and TiDB Dashboard Proxy. It provides dynamic information for components to use, which avoids modifying ConfigMap that may result in Pod rolling update.<\/li>\n\n\n\n<li>Reclaim Policy Manager syncs the configuration of <code>tc.Spec.PVReclaimPolicy<\/code>. By default, the PV reclaim policy is set to <code>Retain<\/code> to reduce the risk of data loss.<\/li>\n\n\n\n<li>Orphan Pod Cleaner cleans up a Pod when the PVC fails to be created. Then the StatefulSet Controller tries again to create Pods and the corresponding PVCs.<\/li>\n\n\n\n<li>PVC Cleaner removes PVCs that are marked deletable.<\/li>\n\n\n\n<li>PVC Resizer scales out PVCs. When you run TiDB Operator on the cloud, you can change the size of PVCs by modifying the storage configuration in <code>TidbCluster<\/code>.<\/li>\n\n\n\n<li>Meta Manager syncs <code>StoreIDLabel<\/code>, <code>MemberIDLabel<\/code>, \uadf8\ub9ac\uace0 <code>NamespaceLabel<\/code> to the labels of Pods, PVCs, and PVs.<\/li>\n\n\n\n<li>TiDBCluster Status Manager syncs information related to <code>TidbMonitor<\/code> and TiDB Dashboard.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>By now, you have learned the design of TiDB components&#8217; control loop, including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>How the reconcile functions follow their corresponding procedures to check the component resources<\/li>\n\n\n\n<li>How the reconcile functions turn the user&#8217;s desired state into the actual component state<\/li>\n<\/ul>\n\n\n\n<p>Almost all control loops in TiDB Operator conform to the design logic described in this article. In future posts, I&#8217;ll further explain <a href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-4-implement-component-control-loop\/\">how this logic is applied to each component to manage the component lifecycle<\/a>.<\/p>\n\n\n\n<p>If you have any questions or ideas about TiDB Operator, feel free to <a href=\"https:\/\/slack.tidb.io\/invite?team=tidb-community&amp;channel=sig-k8s&amp;ref=pingcap-blog\">join our Slack channel<\/a> or join our discussions at <a href=\"https:\/\/github.com\/pingcap\/tidb-operator\">pingcap\/tidb-operator<\/a>!<\/p>","protected":false},"excerpt":{"rendered":"<p>Learn about TiDB Operator&#8217;s component control loop and how it manages TiDB&#8217;s component lifecycle.<\/p>","protected":false},"author":67,"featured_media":1358,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ub_ctt_via":"","footnotes":""},"categories":[6],"tags":[84],"class_list":["post-1356","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engineering","tag-tidb-operator"],"acf":[],"featured_image_src":"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg","author_info":{"display_name":"Yiwen Chen","author_link":"https:\/\/www.pingcap.com\/ko\/blog\/author\/yiwen-chen\/"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>TiDB Operator Source Code Reading (III): The Component Control Loop<\/title>\n<meta name=\"description\" content=\"You&#039;ll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TiDB Operator Source Code Reading (III): The Component Control Loop\" \/>\n<meta property=\"og:description\" content=\"You&#039;ll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\" \/>\n<meta property=\"og:site_name\" content=\"TiDB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/pingcap2015\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-21T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-14T14:22:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1999\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yiwen Chen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@PingCAP\" \/>\n<meta name=\"twitter:site\" content=\"@PingCAP\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yiwen Chen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\"},\"author\":{\"name\":\"Yiwen Chen\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/person\/5e8e0624ab59c4f01eb367e8c9869ab2\"},\"headline\":\"TiDB Operator Source Code Reading (III): The Component Control Loop\",\"datePublished\":\"2021-07-21T00:00:00+00:00\",\"dateModified\":\"2025-11-14T14:22:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\"},\"wordCount\":1810,\"publisher\":{\"@id\":\"https:\/\/www.pingcap.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg\",\"keywords\":[\"TiDB Operator\"],\"articleSection\":[\"Engineering\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\",\"url\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\",\"name\":\"TiDB Operator Source Code Reading (III): The Component Control Loop\",\"isPartOf\":{\"@id\":\"https:\/\/www.pingcap.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg\",\"datePublished\":\"2021-07-21T00:00:00+00:00\",\"dateModified\":\"2025-11-14T14:22:02+00:00\",\"description\":\"You'll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage\",\"url\":\"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg\",\"width\":1999,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pingcap.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TiDB Operator Source Code Reading (III): The Component Control Loop\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pingcap.com\/#website\",\"url\":\"https:\/\/www.pingcap.com\/\",\"name\":\"TiDB\",\"description\":\"TiDB | SQL at Scale\",\"publisher\":{\"@id\":\"https:\/\/www.pingcap.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pingcap.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pingcap.com\/#organization\",\"name\":\"PingCAP\",\"url\":\"https:\/\/www.pingcap.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png\",\"width\":811,\"height\":232,\"caption\":\"PingCAP\"},\"image\":{\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/pingcap2015\",\"https:\/\/x.com\/PingCAP\",\"https:\/\/linkedin.com\/company\/pingcap\",\"https:\/\/youtube.com\/channel\/UCuq4puT32DzHKT5rU1IZpIA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/person\/5e8e0624ab59c4f01eb367e8c9869ab2\",\"name\":\"Yiwen Chen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/www.pingcap.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg\",\"contentUrl\":\"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg\",\"caption\":\"Yiwen Chen\"},\"url\":\"https:\/\/www.pingcap.com\/ko\/blog\/author\/yiwen-chen\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TiDB Operator Source Code Reading (III): The Component Control Loop","description":"You'll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/","og_locale":"ko_KR","og_type":"article","og_title":"TiDB Operator Source Code Reading (III): The Component Control Loop","og_description":"You'll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.","og_url":"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/","og_site_name":"TiDB","article_publisher":"https:\/\/facebook.com\/pingcap2015","article_published_time":"2021-07-21T00:00:00+00:00","article_modified_time":"2025-11-14T14:22:02+00:00","og_image":[{"width":1999,"height":667,"url":"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg","type":"image\/jpeg"}],"author":"Yiwen Chen","twitter_card":"summary_large_image","twitter_creator":"@PingCAP","twitter_site":"@PingCAP","twitter_misc":{"Written by":"Yiwen Chen","Est. reading time":"9\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#article","isPartOf":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/"},"author":{"name":"Yiwen Chen","@id":"https:\/\/www.pingcap.com\/#\/schema\/person\/5e8e0624ab59c4f01eb367e8c9869ab2"},"headline":"TiDB Operator Source Code Reading (III): The Component Control Loop","datePublished":"2021-07-21T00:00:00+00:00","dateModified":"2025-11-14T14:22:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/"},"wordCount":1810,"publisher":{"@id":"https:\/\/www.pingcap.com\/#organization"},"image":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg","keywords":["TiDB Operator"],"articleSection":["Engineering"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/","url":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/","name":"TiDB Operator Source Code Reading (III): The Component Control Loop","isPartOf":{"@id":"https:\/\/www.pingcap.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage"},"image":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage"},"thumbnailUrl":"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg","datePublished":"2021-07-21T00:00:00+00:00","dateModified":"2025-11-14T14:22:02+00:00","description":"You'll learn how the control loop events are orchestrated during TiDB cluster lifecycle management and how these events manage resources.","breadcrumb":{"@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/"]}]},{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#primaryimage","url":"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg","contentUrl":"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg","width":1999,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/www.pingcap.com\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pingcap.com\/"},{"@type":"ListItem","position":2,"name":"TiDB Operator Source Code Reading (III): The Component Control Loop"}]},{"@type":"WebSite","@id":"https:\/\/www.pingcap.com\/#website","url":"https:\/\/www.pingcap.com\/","name":"\ud2f0DB","description":"TiDB | SQL at Scale","publisher":{"@id":"https:\/\/www.pingcap.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pingcap.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/www.pingcap.com\/#organization","name":"PingCAP","url":"https:\/\/www.pingcap.com\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/","url":"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png","contentUrl":"https:\/\/static.pingcap.com\/files\/2021\/11\/pingcap-logo.png","width":811,"height":232,"caption":"PingCAP"},"image":{"@id":"https:\/\/www.pingcap.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/pingcap2015","https:\/\/x.com\/PingCAP","https:\/\/linkedin.com\/company\/pingcap","https:\/\/youtube.com\/channel\/UCuq4puT32DzHKT5rU1IZpIA"]},{"@type":"Person","@id":"https:\/\/www.pingcap.com\/#\/schema\/person\/5e8e0624ab59c4f01eb367e8c9869ab2","name":"Yiwen Chen","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/www.pingcap.com\/#\/schema\/person\/image\/","url":"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg","contentUrl":"https:\/\/static.pingcap.com\/files\/2022\/10\/17234942\/avatar.jpg","caption":"Yiwen Chen"},"url":"https:\/\/www.pingcap.com\/ko\/blog\/author\/yiwen-chen\/"}]}},"grav_blocks":false,"card_markup":"<a class=\"card-resource bg-white\" href=\"https:\/\/www.pingcap.com\/ko\/blog\/tidb-operator-source-code-reading-3-component-control-loop\/\"><div class=\"card-resource__image-container\"><img class=\"card-resource__image\" alt=\"tidb-operator-source-code-reading-3-component-control-loop.jpg\" src=\"https:\/\/static.pingcap.com\/files\/2021\/07\/tidb-operator-source-code-reading-3-component-control-loop.jpg\" loading=\"lazy\" width=1999 height=667 \/><\/div><div class=\"card-resource__content-container\"><div class=\"card-resource__content-head\"><div class=\"card-resource__category\">Engineering<\/div><\/div><h5 class=\"card-resource__title\">TiDB Operator Source Code Reading (III): The Component Control Loop<\/h5><\/div><\/a>","_links":{"self":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts\/1356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/users\/67"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/comments?post=1356"}],"version-history":[{"count":7,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts\/1356\/revisions"}],"predecessor-version":[{"id":30502,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/posts\/1356\/revisions\/30502"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/media\/1358"}],"wp:attachment":[{"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/media?parent=1356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/categories?post=1356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pingcap.com\/ko\/wp-json\/wp\/v2\/tags?post=1356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}