<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dmlcvt &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/tag/dmlcvt/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Fri, 07 Aug 2026 07:40:20 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>dmlcvt &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>案例：达梦数据库利用dmlcvt解析归档日志定位删除事务</title>
		<link>https://www.lemonary.cn/%e6%a1%88%e4%be%8b%ef%bc%9a%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e5%88%a9%e7%94%a8dmlcvt%e8%a7%a3%e6%9e%90%e5%bd%92%e6%a1%a3%e6%97%a5%e5%bf%97%e5%ae%9a%e4%bd%8d%e5%88%a0%e9%99%a4%e4%ba%8b/</link>
					<comments>https://www.lemonary.cn/%e6%a1%88%e4%be%8b%ef%bc%9a%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e5%88%a9%e7%94%a8dmlcvt%e8%a7%a3%e6%9e%90%e5%bd%92%e6%a1%a3%e6%97%a5%e5%bf%97%e5%ae%9a%e4%bd%8d%e5%88%a0%e9%99%a4%e4%ba%8b/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Fri, 07 Aug 2026 07:34:10 +0000</pubDate>
				<category><![CDATA[DM]]></category>
		<category><![CDATA[dmlcvt]]></category>
		<category><![CDATA[SQLLOG]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=3267</guid>

					<description><![CDATA[一、问题背景 客户反馈系统中某条数据丢失，需确认： 二、排查环境 数据库版本：8.1.3.62 Pack31  [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、问题背景</h2>



<p class="wp-block-paragraph">客户反馈系统中某条数据丢失，需确认：</p>



<ul class="wp-block-list">
<li>该条数据是否成功插入？</li>



<li>若已插入，数据是如何丢失的？</li>
</ul>



<h2 class="wp-block-heading">二、排查环境</h2>



<p class="wp-block-paragraph">数据库版本：8.1.3.62 Pack31</p>



<h2 class="wp-block-heading">三、排查步骤</h2>



<p class="wp-block-paragraph">步骤1：使用dmlcvt解析归档日志</p>



<p class="wp-block-paragraph">利用达梦dmlcvt工具解析指定时间范围内的归档日志文件，输出rec_info*.txt等文件，其中包含所有记录级操作信息。</p>



<pre class="wp-block-code"><code>dmlcvt F_TYPE=1 F_PATH=/归档目录 OP_TYPE=1 REC_DATA=1 OUT_PATH=/输出目录</code></pre>



<p class="wp-block-paragraph">步骤2：统计各表的操作次数，定位问题表</p>



<p class="wp-block-paragraph">编写统计脚本<code>analyze_rec.sh</code>，从<code>rec_info*.txt</code>中提取所有<code>UREC_INS</code>（插入）和<code>UREC_DEL</code>（删除）操作，按<code>tabid</code>（表ID）聚合计数，并按数量从大到小排序。</p>



<p class="wp-block-paragraph">脚本内容：</p>



<pre class="wp-block-code"><code>#!/bin/bash
# 用法: ./analyze_rec.sh rec_info*.txt
# 功能: 统计所有表的增删操作，按数量从大到小排序

awk '{
    match($0, /UREC_&#91;A-Z]+:/);
    Operation = substr($0, RSTART, RLENGTH);
    match($0, /tabid:&#91;0-9a-fA-Fx]+/);
    tabid = substr($0, RSTART, RLENGTH);
    if (Operation != "" &amp;&amp; tabid != "") {
        print Operation, tabid;
    }
}' "$@" | sort | uniq -c | sort -rn</code></pre>



<p class="wp-block-paragraph">执行命令：</p>



<pre class="wp-block-code"><code>./analyze_rec.sh rec_info*.txt &gt; res.log</code></pre>



<p class="wp-block-paragraph">输出示例（部分）：</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="233" height="468" src="https://www.lemonary.cn/wp-content/uploads/2026/08/image.png" alt="" class="wp-image-3268" srcset="https://www.lemonary.cn/wp-content/uploads/2026/08/image.png 233w, https://www.lemonary.cn/wp-content/uploads/2026/08/image-149x300.png 149w" sizes="(max-width: 233px) 100vw, 233px" /></figure>



<p class="wp-block-paragraph">排查发现：目标数据所在表tabid:0x47f()共有 4条删除记录，数量虽少，但极有可能包含丢失的那条数据。</p>



<p class="wp-block-paragraph">步骤3：从rec_info文件中提取事务号</p>



<pre class="wp-block-code"><code>grep -aE "UREC_DEL.*tabid:0x47f()" rec_info*.txt &gt; 0x47f.del</code></pre>



<p class="wp-block-paragraph">输出示例：</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="64" src="https://www.lemonary.cn/wp-content/uploads/2026/08/image-1-1024x64.png" alt="" class="wp-image-3269" srcset="https://www.lemonary.cn/wp-content/uploads/2026/08/image-1-1024x64.png 1024w, https://www.lemonary.cn/wp-content/uploads/2026/08/image-1-300x19.png 300w, https://www.lemonary.cn/wp-content/uploads/2026/08/image-1-768x48.png 768w, https://www.lemonary.cn/wp-content/uploads/2026/08/image-1.png 1042w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">提取到4个事务号：</p>



<ul class="wp-block-list">
<li><code>13681865115</code></li>



<li><code>13681901417</code></li>



<li><code>13684820518</code></li>



<li><code>13688504573</code></li>
</ul>



<p class="wp-block-paragraph">步骤4：关联SQL日志定位删除语句</p>



<p class="wp-block-paragraph">用步骤3提取的事务号作为关键字，在SQL日志中搜索对应的日志</p>



<pre class="wp-block-code"><code>grep -aE "trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13681865115</span>|trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13681901417</span>|trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13684820518</span>|trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13688504573</span>" dmsql_*.log > deltrx.log</code></pre>



<p class="wp-block-paragraph">在SQL日志中定位到具体的DELETE语句，确认数据是被业务方的删除操作所删除。</p>



<h2 class="wp-block-heading">四、结论</h2>



<p class="wp-block-paragraph">通过归档日志解析和SQL日志关联分析，得出以下结论：</p>



<p class="wp-block-paragraph">数据是否插入成功？ 是（rec_info中存在对应UREC_INS记录）</p>



<p class="wp-block-paragraph">数据如何丢失？ 被业务方执行的 DELETE语句 删除（SQL日志中定位到具体语句）</p>



<h2 class="wp-block-heading">五、经验总结</h2>



<ul class="wp-block-list">
<li>解析归档：<code>dmlcvt</code>解析归档日志</li>



<li>定位可疑表：<code>SYSOBJECTS</code>表查看ID，转化成十六进制</li>



<li>提取事务号：从<code>rec_info</code>中提取<code>nrec_tid</code></li>



<li>定位SQL：用事务号搜索SQL日志</li>
</ul>



<h2 class="wp-block-heading">六、附录：关键命令速查</h2>



<pre class="wp-block-code"><code># 1. 统计各表操作次数
./analyze_rec.sh rec_info*.txt > res.log

# 2. 查找目标表的所有删除记录及事务号
grep -aE "UREC_DEL.*tabid:0x47f()" rec_info*.txt > 0x47f.del

# 3. 用事务号在SQL日志中定位删除语句
grep -aE "trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13681865115</span>|trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13681901417</span>|trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13684820518</span>|trxid:<span style="background-color: initial; font-family: inherit; font-size: inherit; text-align: initial; color: initial;">13688504573</span>" dmsql_*.log > deltrx.log

# 4. 确认数据曾插入成功
grep -aE "UREC_INS.*tabid:0x47f()" rec_info*.txt

# 5. 表ID转化成十六进制
SELECT 
    ID,
    UTL_RAW.CAST_FROM_INT(ID) AS HEX_ID
FROM SYSOBJECTS
WHERE NAME = 'TABNAME'
  AND SCHID = (SELECT ID FROM SYSOBJECTS WHERE TYPE$ = 'SCH' AND NAME = 'SCHNAME');</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e6%a1%88%e4%be%8b%ef%bc%9a%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e5%88%a9%e7%94%a8dmlcvt%e8%a7%a3%e6%9e%90%e5%bd%92%e6%a1%a3%e6%97%a5%e5%bf%97%e5%ae%9a%e4%bd%8d%e5%88%a0%e9%99%a4%e4%ba%8b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
