<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>TiDB on DBA学习笔记</title><link>https://blog.zhangjt.fun/tags/tidb/</link><description>Recent content in TiDB on DBA学习笔记</description><generator>Hugo</generator><language>zh-cn</language><managingEditor>281304173@qq.com (张天师)</managingEditor><webMaster>281304173@qq.com (张天师)</webMaster><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Tue, 20 Oct 2026 17:21:57 +0800</lastBuildDate><atom:link href="https://blog.zhangjt.fun/tags/tidb/index.xml" rel="self" type="application/rss+xml"/><item><title>一次TiDB负载搞排查</title><link>https://blog.zhangjt.fun/tidb-high-cpu-usage/</link><pubDate>Tue, 24 May 2022 16:11:36 +0800</pubDate><author>281304173@qq.com (张天师)</author><guid>https://blog.zhangjt.fun/tidb-high-cpu-usage/</guid><description>&lt;h2 id="背景" class="headerLink">
 &lt;a href="#%e8%83%8c%e6%99%af" class="header-mark">&lt;/a>1. 背景&lt;/h2>&lt;ul>
&lt;li>TiDB Server两个节点CPU使用率都比较高
&lt;figure>&lt;a class="lightgallery" href="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/cpu-usage-nodes.svg" title="TiDB Server 两个节点 CPU 使用率" data-thumbnail="/images/posts/tidb-high-cpu-usage/cpu-usage-nodes.svg">
 &lt;img
 
 loading="lazy"
 src="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/cpu-usage-nodes.svg"
 srcset="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/cpu-usage-nodes.svg, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/cpu-usage-nodes.svg 1.5x, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/cpu-usage-nodes.svg 2x"
 sizes="auto"
 alt="TiDB Server 两个节点 CPU 使用率">
 &lt;/a>&lt;/figure>&lt;/li>
&lt;li>查看QPS指标，可以看到14点到19点之间是基本没有流量的
&lt;figure>&lt;a class="lightgallery" href="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/qps-metrics.svg" title="QPS 指标，14 点到 19 点基本无流量" data-thumbnail="/images/posts/tidb-high-cpu-usage/qps-metrics.svg">
 &lt;img
 
 loading="lazy"
 src="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/qps-metrics.svg"
 srcset="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/qps-metrics.svg, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/qps-metrics.svg 1.5x, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/qps-metrics.svg 2x"
 sizes="auto"
 alt="QPS 指标，14 点到 19 点基本无流量">
 &lt;/a>&lt;/figure>&lt;/li>
&lt;li>登陆机器可以发现，有很多连接其实已经失效，但是还残留服务器上：
&lt;figure>&lt;a class="lightgallery" href="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/stale-connections.svg" title="服务器上残留的失效连接" data-thumbnail="/images/posts/tidb-high-cpu-usage/stale-connections.svg">
 &lt;img
 
 loading="lazy"
 src="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/stale-connections.svg"
 srcset="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/stale-connections.svg, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/stale-connections.svg 1.5x, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/stale-connections.svg 2x"
 sizes="auto"
 alt="服务器上残留的失效连接">
 &lt;/a>&lt;/figure>&lt;/li>
&lt;li>怀疑Server负载高和这些诡异的SQL有关系，即便没有释放，也没办法KILL，但是还是占用了一个核的CPU
&lt;figure>&lt;a class="lightgallery" href="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/2022-05-29-mxWOpSfh5PwAsbL.png" title="20220529204849" data-thumbnail="/images/posts/tidb-high-cpu-usage/2022-05-29-mxWOpSfh5PwAsbL.png">
 &lt;img
 
 loading="lazy"
 src="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/2022-05-29-mxWOpSfh5PwAsbL.png"
 srcset="https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/2022-05-29-mxWOpSfh5PwAsbL.png, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/2022-05-29-mxWOpSfh5PwAsbL.png 1.5x, https://blog.zhangjt.fun/images/posts/tidb-high-cpu-usage/2022-05-29-mxWOpSfh5PwAsbL.png 2x"
 sizes="auto"
 alt="20220529204849">
 &lt;/a>&lt;/figure>
&lt;ul>
&lt;li>&lt;a href="https://github.com/pingcap/tidb/pull/29212" target="_blank" rel="noopener noreferrer">https://github.com/pingcap/tidb/pull/29212&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/pingcap/tidb/issues/24031" target="_blank" rel="noopener noreferrer">https://github.com/pingcap/tidb/issues/24031&lt;/a>&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h2 id="解决方案" class="headerLink">
 &lt;a href="#%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88" class="header-mark">&lt;/a>2. 解决方案&lt;/h2>&lt;ol>
&lt;li>
&lt;p>将流量转移到其他机器，可选途径有：&lt;/p></description></item></channel></rss>