<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Troubleshooting scenarios on kbdiag</title><link>https://kevin-wenyu.github.io/kbdiag-docs/docs/scenarios/</link><description>Recent content in Troubleshooting scenarios on kbdiag</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 27 Sep 2026 13:49:17 +0800</lastBuildDate><atom:link href="https://kevin-wenyu.github.io/kbdiag-docs/docs/scenarios/index.xml" rel="self" type="application/rss+xml"/><item><title>Find long-running SQL</title><link>https://kevin-wenyu.github.io/kbdiag-docs/docs/scenarios/slow-sql/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kevin-wenyu.github.io/kbdiag-docs/docs/scenarios/slow-sql/</guid><description>&lt;p&gt;Captured on 2026-09-27 (UTC+08) on a local KingbaseES V008R006C009B0014 primary, database &lt;code&gt;test&lt;/code&gt;, using &lt;code&gt;~/kbdiag&lt;/code&gt; built from Go source commit &lt;code&gt;93bf65d&lt;/code&gt; (static linux/amd64 binary). This is lab evidence, not production validation. PIDs, counts and timings belong to this capture only. A fault-injection script started &lt;code&gt;select pg_sleep(3600);&lt;/code&gt;, a statement that only sleeps. It tests detection, not CPU or disk pressure.&lt;/p&gt;&#10;&lt;p&gt;kbdiag 2.0 has no slow-SQL threshold yet: a long statement is listed and sorted, but not a WARN on its own. It becomes a finding when it holds a transaction open too long (&lt;code&gt;txn&lt;/code&gt;) or makes others wait for a lock (&lt;code&gt;locks&lt;/code&gt;).&lt;/p&gt;</description></item><item><title>Investigate lock waits</title><link>https://kevin-wenyu.github.io/kbdiag-docs/docs/scenarios/lock-waits/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kevin-wenyu.github.io/kbdiag-docs/docs/scenarios/lock-waits/</guid><description>&lt;p&gt;Captured on 2026-09-27 (UTC+08) on a local KingbaseES V008R006C009B0014 primary, database &lt;code&gt;test&lt;/code&gt;, using &lt;code&gt;~/kbdiag&lt;/code&gt; built from Go source commit &lt;code&gt;93bf65d&lt;/code&gt; (static linux/amd64 binary). This is lab evidence, not production validation. PIDs, counts and timings belong to this capture only. A fault-injection script opened a transaction that took an &lt;code&gt;ACCESS EXCLUSIVE&lt;/code&gt; lock on a test table and then sat idle, and a second session tried to read the table.&lt;/p&gt;&#10;&lt;h2 id="1-who-is-waiting"&gt;1. Who is waiting?&#10;&lt;/h2&gt;&#10;&lt;div class="td-code td-code--untitled" id="td-code-a01fbf3f-fence-0" data-td-code data-td-code-auto-id&#10; data-td-language="bash" data-td-line-count="2"&gt;&#10; &lt;div class="td-code__viewport" id="td-code-a01fbf3f-fence-0-viewport" data-td-code-viewport&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;~/kbdiag locks&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;EXIT_CODE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;div class="td-code td-code--untitled" id="td-code-a01fbf3f-fence-1" data-td-code data-td-code-auto-id&#10; data-td-language="text" data-td-line-count="13"&gt;&#10; &lt;div class="td-code__viewport" id="td-code-a01fbf3f-fence-1-viewport" data-td-code-viewport&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;locks WARN (KingbaseES V008R006C009B0014, primary, system@local, 2026-09-27T13:36:33+08:00)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[WARN] lock.waiting session 1048829 has waited 13s for AccessShareLock on public.kbdiag_inj_lock, blocked by 1048819&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; verify: kbdiag session 1048819 # what the blocking session is doing&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;blockers: 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pid blocks holds&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 1048819 1 public.kbdiag_inj_lock AccessExclusiveLock&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;waiting: 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pid object wants waited blocked by&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; 1048829 public.kbdiag_inj_lock AccessShareLock 13s 1048819&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;EXIT_CODE=1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;&lt;/div&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Session 1048829 has waited 13 seconds for &lt;code&gt;AccessShareLock&lt;/code&gt; on &lt;code&gt;public.kbdiag_inj_lock&lt;/code&gt;; the direct blocker is 1048819. Waits over 10 seconds are a WARN (&lt;code&gt;--lock-wait-warn&lt;/code&gt; changes this).&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;blockers&lt;/code&gt; comes first, because the first question is who is in the way. It shows 1048819 blocks one session and holds &lt;code&gt;AccessExclusiveLock&lt;/code&gt; on the table. When one blocker holds up dozens of sessions, it is the top row.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;waiting&lt;/code&gt; lists each waiting session, longest wait first. The wait is measured from the waiter&amp;rsquo;s last state change, so it can overstate the wait a little, never understate it.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="2-what-is-the-blocker-doing"&gt;2. What is the blocker doing?&#10;&lt;/h2&gt;&#10;&lt;p&gt;Follow the &lt;code&gt;verify&lt;/code&gt; line:&lt;/p&gt;</description></item></channel></rss>