<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="/feeds/rss-style.xsl" type="text/xsl"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>暮言</title>
        <link>https://critas.wang/</link>
        <description>Critas 的个人技术博客，记录学习笔记与技术分享，不含任何商业推广。</description>
        <lastBuildDate>Tue, 13 Oct 2026 03:01:26 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>Astro-Theme-Retypeset with Feed for Node.js</generator>
        <language>zh</language>
        <copyright>Copyright © 2026 Critas</copyright>
        <atom:link href="https://critas.wang/rss.xml" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[Apache IoTDB V2.0.11 版本解析：JDK 17、IoTDB Edge 与元数据租约]]></title>
            <link>https://critas.wang/posts/iotdb-v2011-release-notes/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-v2011-release-notes/</guid>
            <pubDate>Mon, 14 Sep 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB V2.0.11 变更解析：最低 JDK 提升到 17 并完成 javax→jakarta 迁移，新增 IoTDB Edge 单 JVM 边缘版，元数据租约框架补齐高可用。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>Apache IoTDB V2.0.11 已发布，发布分支为 <code>rc/2.0.11</code>，tag 提交日期 2026-09-07。</p>
<p>从 V2.0.10 到 V2.0.11 共 305 个 commit（<code>git rev-list --count v2.0.10..v2.0.11</code>）。两个 tag 之间的 diff 是 2,647 个文件、+154,535 / −17,623 行，其中 Java 文件 2,479 个、测试文件 509 个。commit 数量比上一周期（407 个）少，但改动量没有下降。这些改动里相当一部分不是功能：javax 到 jakarta 的命名空间迁移和中文 i18n 铺开两项就占了大量行数。</p>
<p>本周期与 AINode 相关的 commit 只有 1 个（<code>#17822</code>，移除 Chronos2 DataLoader 的 pin_memory 选项），Release Notes 的 Features 部分也没有 AI 条目。对比 V2.0.8 的 Chronos-2 和 V2.0.10 的 Toto、Moirai2，这一版在 AI 侧没有新增能力。</p>
<p>本文基于 <a href="https://dlcdn.apache.org/iotdb/2.0.11/RELEASE_NOTES.md">2.0.11 Release Notes</a> 和本地 <code>apache/iotdb</code> 仓库中 <code>v2.0.10..v2.0.11</code> 的实际 diff 写成。文中 PR 编号均可在<a href="https://github.com/apache/iotdb">官方仓库</a>检索。</p>
<hr />
<h2>变更一：最低 JDK 提升到 17</h2>
<p>Release Notes 的 Break change 只有一行：</p>
<pre><code>## Break change
- This version raises the minimum required JDK version to 17.
</code></pre>
<p>这条变更在六月份的<a href="/posts/iotdb-jdk17-jakarta-migration-preview/">预告文章</a>里已经分析过，来源是 PR <a href="https://github.com/apache/iotdb/pull/17859">#17859</a>（Upgrade minimum JDK to 17 and migrate JavaX to Jakarta）。当时的判断是：Jetty 12、Jersey 3、Logback 1.5 这批 Web 技术栈已经不再提供 JDK 8 + javax 的新版本，继续停留在旧基线等于放弃这些库的后续修复。</p>
<p>随 JDK 一起抬升的还有一批依赖。对比两个 tag 的 <code>pom.xml</code>：</p>
<table>
<thead>
<tr>
<th>项</th>
<th>V2.0.10</th>
<th>V2.0.11</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>maven.compiler.source</code> / <code>target</code></td>
<td><code>1.8</code></td>
<td><code>17</code></td>
</tr>
<tr>
<td>TsFile</td>
<td>2.3.1</td>
<td>2.4.0</td>
</tr>
<tr>
<td>Apache Ratis</td>
<td>3.2.2</td>
<td>3.3.0</td>
</tr>
<tr>
<td>Apache Thrift</td>
<td>0.14.1</td>
<td>0.23.0</td>
</tr>
<tr>
<td><code>iotdb-tools-thrift</code></td>
<td>0.14.1.0</td>
<td>0.23.0.0</td>
</tr>
</tbody>
</table>
<p>Thrift 从 0.14 到 0.23 跨了九个 minor 版本。<code>iotdb-tools-thrift</code> 需要同步跳版，因为 IoTDB 的 Thrift 代码生成器是自维护的，生成器版本必须和运行时协议库一致，否则生成的 stub 与运行时不匹配。</p>
<p>Release Notes 里 Break change 只有一行，但 diff 有 2,647 个文件，原因在于几块工作叠在一起：javax 到 jakarta 的机械替换、中文 i18n 铺开，以及一批新增功能和修复。前两块属于工程规整，不产生用户可见的新功能。对使用方来说，升级风险集中在兼容性上，而不是行为变化。</p>
<p>JDK 基线抬升也会传导到客户端。本周期 C++ 客户端有两处配套改动：<a href="https://github.com/apache/iotdb/pull/17987">#17987</a> 改为默认用 OpenSSL 3.x 构建并捆绑运行时依赖；<a href="https://github.com/apache/iotdb/pull/17801">#17801</a> 重构 SDK，引入线程安全的 <code>SessionPool</code>、启用 RPC 压缩、加固缓冲区边界。服务端换了 TLS 栈之后，客户端如果还在老 OpenSSL 上，握手阶段就会先出问题。</p>
<hr />
<h2>变更二：IoTDB Edge</h2>
<p>Release Notes 对 Edge 版的描述是：把 ConfigNode 和 DataNode 合并到一个进程，两者合计内存控制在 512 MB 以内，目标负载约为 1 万个测点、1 Hz 读写。第一版主要调整 JVM 和默认配置参数，后续版本再向 DataNode 与 ConfigNode 的架构级融合演进。</p>
<p>动机是进程的固定开销。云端部署下 ConfigNode 和 DataNode 各自一个 JVM 没问题，但在边缘网关上，每个 JVM 的 metaspace、code cache、GC 结构和线程栈都是重复开销。</p>
<p>从源码看，Edge 版不是新写一个数据库，而是在现有 ConfigNode 和 DataNode 之上加了一层进程内启动编排：</p>
<pre><code>distribution/src/assembly/edge.xml                          分发包定义（zip + dir）
distribution/src/assembly/resources/conf-edge/logback-edge.xml
iotdb-core/confignode/src/main/java/org/apache/iotdb/edge/EdgeNode.java
iotdb-core/node-commons/src/assembly/resources/conf/edge/iotdb-system.properties
scripts/conf/edge-env.sh
scripts/sbin/start-edge.sh / stop-edge.sh
scripts/tools/ops/daemon-edge.sh / destroy-edge.sh
</code></pre>
<p><code>EdgeNode.main()</code> 处理的是两个服务如何在一个进程里有序启动。ConfigNode 先在后台线程启动，主线程以 500ms 间隔探测 ConfigNode 的内部 RPC 端口，最长等 300 秒；端口可连接后再等 5 秒，让单节点 ConfigNode 的 Ratis 选主完成，然后 DataNode 在主线程启动。两个服务各靠自己的非 daemon 线程维持 JVM 存活。任一节点致命失败会终止整个进程，源码注释里写明这是预期的单进程语义，进程内不做隔离。</p>
<p>内存参数在 <code>scripts/conf/edge-env.sh</code>：</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>默认值</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>ON_HEAP_MEMORY</code></td>
<td>224M</td>
<td>堆上限（<code>-Xmx</code>）</td>
</tr>
<tr>
<td><code>INIT_HEAP_MEMORY</code></td>
<td>64M</td>
<td>初始堆</td>
</tr>
<tr>
<td><code>OFF_HEAP_MEMORY</code></td>
<td>96M</td>
<td>直接内存（<code>-XX:MaxDirectMemorySize</code>）</td>
</tr>
</tbody>
</table>
<p>三者相加 320 MB，距离 512 MB 的目标留了约 200 MB 给 metaspace、code cache 和线程栈。脚本启用了 <code>-XX:+CrashOnOutOfMemoryError</code>，并倾向选用串行 GC，注释理由是固定内存开销最低。这几个变量都支持环境变量覆盖。另外 <a href="https://github.com/apache/iotdb/pull/17765">#17765</a> 让 env 脚本能在容器里识别 cgroup 内存限额。</p>
<p>Edge 相关 commit 的时间集中在发布前十天：</p>
<pre><code>2026-08-28  #18530  Disable unused pipe/sub logic
2026-08-31  #18538  Add IoTDB Edge distribution
2026-08-31  #18552  Add daemon and cleanup tools for IoTDB Edge
2026-09-02  #18566  Tune Edge compaction and TsFile defaults
2026-09-02  #18568  Update pipe config for edge version
2026-09-04  #18576  Change default edge ratis configuration
2026-09-04  #18580  Bound PartitionInfo snapshot buffers
2026-09-06  #18584  Make Edge query and load-event thread pools configurable
2026-09-07  tag v2.0.11
</code></pre>
<p>从第一个 Edge commit 到发版是 10 天。这批 commit 的内容集中在 Ratis 配置、压缩策略、TsFile 默认值、线程池规模和快照缓冲上限上，都是在真实资源约束下跑起来才会暴露的参数。</p>
<p>配套 CI 已建立：<code>.github/workflows/edge-it.yml</code>、<code>integration-test/src/main/java/org/apache/iotdb/itbase/category/EdgeIT.java</code>，以及 Windows 侧的 <code>test-edge-windows.ps1</code> 和 <code>check-edge.ps1</code>。</p>
<hr />
<h2>变更三：元数据租约与自隔离</h2>
<p>Release Notes 里有一条 High Availability：为表管理、设备管理、可写视图管理、TTL 管理、数据库管理和用户权限提供高可用。对应的是 commit <code>d02e6af5</code>（A lease-based self-fencing framework to enable high availability for table metadata operations）和 <a href="https://github.com/apache/iotdb/pull/18425">#18425</a>（authority 模块高可用）。</p>
<p>要理解这个框架解决的问题，先看元数据的流向。IoTDB 的表结构、设备属性、模板、TTL、权限由 ConfigNode 持有，并主动推送到各 DataNode 缓存。DataNode 在查询和写入时读本地缓存，不每次都问 ConfigNode。如果某次推送因为网络分区或节点假死没有送达，该 DataNode 会继续按旧 schema 和旧权限服务，而集群已经按新元数据前进了。</p>
<p>租约方案的核心是两个时间常数的约定：</p>
<pre><code>T_fence    DataNode 侧。超过这个时间没收到 ConfigNode 心跳，就放弃信任本地元数据缓存。
           配置项 metadata_lease_fence_ms，默认 20000ms。

T_proceed  ConfigNode 侧。没 ack 的 DataNode 静默超过这个时间，就认为它已经自我隔离，可以继续广播。

安全前提是 T_proceed &gt;= T_fence：只要 ConfigNode 决定继续广播，那个没 ack 的 DataNode
一定已经先一步自我隔离，不会出现它按旧元数据服务、而集群按新元数据前进的情况。
</code></pre>
<p>框架的代码分在两端。DataNode 侧是 <code>MetadataLeaseManager</code>，跟踪租约状态并在超时后触发自隔离，配套 <code>MetadataLeaseMetrics</code> 暴露距上次心跳的时长、<code>MetadataLeaseFencedException</code> 作为隔离期间的异常。ConfigNode 侧是 <code>MetadataBroadcastVerdict</code>（决策逻辑）、<code>ClusterCachePropagator</code>（广播执行）和 <code>DataNodeContactTracker</code>（跟踪各 DataNode 最后成功心跳时间）。</p>
<p><code>MetadataBroadcastVerdict</code> 的判定规则写在类注释里：未 ack 的 DataNode 被认为支持自隔离，这一前提由调用方保证；当所有未 ack 的 DataNode 静默时间都超过 T_proceed 时返回 <code>PROCEED</code>，否则返回 <code>WAIT</code> 直到重试预算耗尽，再返回 <code>FAIL</code>。这段代码是个约 40 行的纯函数，没有锁和 IO。</p>
<p><code>MetadataLeaseManager</code> 内部维护三个状态：<code>NORMAL</code>、<code>CACHE_CLEARING</code>、<code>CACHE_CLEARED</code>。心跳超时后进入清缓存流程，重新收到心跳并完成元数据拉取后回到 <code>NORMAL</code>。两处实现细节：</p>
<ul>
<li>时钟用 <code>System.nanoTime()</code>。类注释说明是为了不受墙上时钟调整影响。租约判定如果依赖系统时间，一次 NTP 校时就可能误触发或漏触发。</li>
<li>隔离动作是一个 action 列表，由各子系统注册。租约管理器本身不关心有哪些缓存要清。diff 里能看到按子系统拆分的测试：<code>DataNodeTableCacheLeaseTest</code>、<code>PartitionCacheLeaseTest</code>、<code>ClusterAuthorityFetcherLeaseTest</code>。</li>
<li>隔离期间的行为是 fail-closed，明确拒绝并抛 <code>MetadataLeaseFencedException</code>，不做降级。</li>
</ul>
<p>这个方案相比让元数据走共识协议的取舍是：共识方案一致性最强，但元数据读在查询和写入的每条路径上都会发生，每次走多数派确认会明显抬高延迟和 ConfigNode 负载。租约方案用有界的过期时间换掉了每次共识，正常路径下 DataNode 读本地缓存没有额外开销，代价是故障期间存在一个最长 T_fence 的窗口，这段时间内集群可能拒绝服务。</p>
<hr />
<h2>变更四：SQL 与查询</h2>
<p>本周期 SQL 层面的新增不多，有几处可以对一下语法和实现的差异。</p>
<h3>只包含 SELECT 子句的 SQL 语句</h3>
<p>Release Notes 的表述是 SQL 语句支持只包含 SELECT 子句。对应 <a href="https://github.com/apache/iotdb/pull/17437">#17437</a>（Support table-less SELECT queries without FROM clause），也就是查询可以不带 FROM、直接由 SELECT 子句构成。</p>
<p>对比两个 tag 的 <code>RelationalSql.g4</code>，<code>querySpecification</code> 规则逐字相同，<code>FROM</code> 早就是可选的：</p>
<pre><code>querySpecification
    : SELECT setQuantifier? selectItem (',' selectItem)*
      (FROM relation (',' relation)*)?        &lt;- 可选
      (WHERE where=booleanExpression)?
    ...
</code></pre>
<p>缺的是执行链路。#17437 只改了 5 个文件、77 行：<code>QueryPlanner</code>、<code>ValuesNode</code>、<code>TableOperatorGenerator</code>、<code>UnaliasSymbolReferences</code>。这和 V2.0.10 里 CTE、集合操作的情况类似，语法先就位，执行后补齐。</p>
<h3>EXPLAIN ANALYZE 的 JSON 输出</h3>
<p><a href="https://github.com/apache/iotdb/pull/17430">#17430</a>。语法变化是在 EXPLAIN 和 EXPLAIN ANALYZE 后面插入一个可选的 <code>(FORMAT identifier)</code>：</p>
<pre><code>v2.0.10:  EXPLAIN (query | executeStatement | executeImmediateStatement)
v2.0.11:  EXPLAIN ('(' FORMAT identifier ')')? (query | executeStatement | executeImmediateStatement)
</code></pre>
<p>格式名用的是 <code>identifier</code> 而不是枚举，说明格式是开放的，后续加别的格式不需要改语法。配套测试里有 <code>ExplainJsonCliOutputIT</code>。</p>
<h3>NEXT 填充</h3>
<p><a href="https://github.com/apache/iotdb/pull/17810">#17810</a>（[IOTDB-17798] Implement table model NEXT fill）。语法规则是 <code>NEXT timeBoundClause? timeColumnClause? fillGroupClause?</code>。它复用了已有的 <code>timeBoundClause</code>、<code>timeColumnClause</code>、<code>fillGroupClause</code>，说明填充功能的语法骨架此前已经搭好，NEXT 是往里加的一种策略。</p>
<h3>别名与 GROUP BY ALL</h3>
<ul>
<li><code>GROUP BY ALL</code>：<a href="https://github.com/apache/iotdb/pull/17937">#17937</a>，自动按所有非聚合列分组。语法层新增了一条产生式，<code>ALL</code> 单独分支，其余仍走 <code>explicitGroupBy</code>。</li>
<li>SELECT 别名用于 GROUP BY 和 ORDER BY：<a href="https://github.com/apache/iotdb/pull/17843">#17843</a>。</li>
<li>SELECT 列表中的横向列别名：<a href="https://github.com/apache/iotdb/pull/17960">#17960</a>（IOTDB-17797）。</li>
</ul>
<p>别名支持是分析器层面的改动。从 churn 看，<code>StatementAnalyzer.java</code> 本周期 +1,181 / −204 行，是改动最大的非新增文件之一。</p>
<h3>M4 表函数</h3>
<p><a href="https://github.com/apache/iotdb/pull/17656">#17656</a> 引入 <code>M4TableFunction</code>，802 行，位置在 <code>node-commons</code> 的 <code>udf/builtin/relational/tvf/</code> 下。</p>
<p>M4 是时序可视化里的降采样聚合方法，每个窗口取 Min、Max、Mean、Median 四个点，用四个点保留窗口的形态特征。它的参数包括 <code>DATA</code>、<code>TIMECOL</code>、<code>SIZE</code>、<code>SLIDE</code>、<code>ORIGIN</code>，同时支持时间窗口（<code>TimeWindowM4DataProcessor</code>）和计数窗口（<code>CountWindowM4DataProcessor</code>），支持分组列和多值列。分区列允许 BLOB 类型，代码注释解释是 M4 只需要在分区列上读写、不需要比较。</p>
<p>把降采样下推到数据库里，可以省掉把全量数据拉到前端再抽样这一步。</p>
<h3>其他语句与函数</h3>
<ul>
<li><a href="https://github.com/apache/iotdb/pull/17292">#17292</a>：自相关、偏度、线性回归等统计类聚合函数</li>
<li><a href="https://github.com/apache/iotdb/pull/16545">#16545</a>：<code>PERCENTILE</code> 聚合函数</li>
<li><a href="https://github.com/apache/iotdb/pull/17456">#17456</a>：<code>CAPACITY</code> 表值函数支持 <code>SLIDE</code> 参数</li>
<li><code>COUNT DATABASE</code>（<a href="https://github.com/apache/iotdb/pull/17705">#17705</a>），不过这个实现在 2.0.10 分支上同样存在</li>
</ul>
<hr />
<h2>变更五：运维、安全与内存</h2>
<h3>配置热加载</h3>
<p><a href="https://github.com/apache/iotdb/pull/17975">#17975</a> 支持集群运行时配置热加载。配套修了 <a href="https://github.com/apache/iotdb/pull/18108">#18108</a>，<code>SHOW CONFIGURATION</code> 之前显示原始值而不是生效值。这两个缺一不可：只有 <code>SHOW CONFIGURATION</code> 能看不能改，只有热加载能改但看不准。</p>
<p>本周期还顺带修了几处热加载的边界问题：<a href="https://github.com/apache/iotdb/pull/18326">#18326</a>（拒绝 NaN 磁盘告警阈值）、<a href="https://github.com/apache/iotdb/pull/18336">#18336</a>（WAL 限流阈值回退）、<a href="https://github.com/apache/iotdb/pull/18327">#18327</a>（无效 WAL 限流阈值持久化）、<a href="https://github.com/apache/iotdb/pull/18091">#18091</a>（procedure 清理器与磁盘阈值）。</p>
<h3>通信加密</h3>
<p>三个 PR 补上了加密能力：</p>
<ul>
<li><a href="https://github.com/apache/iotdb/pull/18026">#18026</a>：Thrift 客户端双向 TLS</li>
<li><a href="https://github.com/apache/iotdb/pull/18080">#18080</a>：Pipe sink 双向 SSL</li>
<li><a href="https://github.com/apache/iotdb/pull/17854">#17854</a>：通用 SSL/TLS 配置</li>
</ul>
<p>单向 TLS 只能验证客户端连的是真服务端，双向 TLS 还能验证服务端接受的是真客户端。跨机房、跨网络的 Pipe 同步链路需要后者。</p>
<p>安全方面还有两处：<a href="https://github.com/apache/iotdb/pull/17508">#17508</a> 修了 JDBC <code>StringUtils.consistentToString</code> 的 BigDecimal 拒绝服务问题；<a href="https://github.com/apache/iotdb/pull/17823">#17823</a> 新增 <code>THREAT_MODEL.md</code>，打通 <code>AGENTS.md → SECURITY.md → THREAT_MODEL.md</code> 路径。</p>
<h3>内存控制</h3>
<p>本周期标题里带 memory 的 commit 有 26 个，覆盖的层次比较多：</p>
<pre><code>协议层    #17911  RPC 自动扩容缓冲区的内存控制
          #18194  修复 RPC 缓冲内存控制未生效
查询层    #17788  查询涉及 mods 时的内存控制
          #18249  对齐 MemTable 位图内存占用
          #18052  内存不足时仍允许 SHOW QUERIES 执行
          #18039  元数据 OOM 诊断信息增强
同步层    #18090  Pipe 接收端内存保护
          #18069  Pipe 日志收敛器 ConfigNode 内存控制
          #18144  Pipe 接收端临时内存管理
          #18141  内存压力下限制 TsFile 解析重试
容器层    #17765  env 脚本识别 cgroup 内存限额
</code></pre>
<p>其中 <a href="https://github.com/apache/iotdb/pull/17911">#17911</a> 把控制点放在协议层。分布式查询中 RPC 缓冲区会随数据量自动扩容，没有上限的话一个大结果集就可能吃掉大量直接内存。放在协议层意味着不管上层算子怎么改，这一层都有兜底。</p>
<h3>集群运维</h3>
<ul>
<li><a href="https://github.com/apache/iotdb/pull/17702">#17702</a>：新增 <code>SHOW CREATE PIPE</code>、<code>SHOW CREATE DATABASE</code>、<code>SHOW CREATE TOPIC</code> 和 <code>ALTER TOPIC</code>，30 个文件、+1,432 行</li>
<li><a href="https://github.com/apache/iotdb/pull/17637">#17637</a>：新增 <code>SHOW REPAIR DATA PARTITION TABLE PROGRESS</code></li>
<li><a href="https://github.com/apache/iotdb/pull/18046">#18046</a>：<code>MIGRATE REGION</code> 支持多 region</li>
<li><a href="https://github.com/apache/iotdb/pull/18114">#18114</a>：修复并发删除快照目录时误判磁盘满并转为只读</li>
<li><a href="https://github.com/apache/iotdb/pull/18097">#18097</a>：区域组清理改为恢复安全提交加重试</li>
<li><a href="https://github.com/apache/iotdb/pull/17981">#17981</a>：避免 Pipe sink task id 把凭据写进日志</li>
<li><a href="https://github.com/apache/iotdb/pull/18002">#18002</a>：修复删除包含别名和 metrics map 的问题</li>
</ul>
<p><code>SHOW CREATE PIPE</code> 对运维的用处是迁移或复制 Pipe 配置时不用再从 <code>SHOW PIPES</code> 的输出里拼 SQL。</p>
<hr />
<h2>变更六：客户端</h2>
<h3>Node.js 客户端</h3>
<p>Release Notes 提到新增 Node.js 客户端，仅支持 2.x 版本。对应独立仓库 <a href="https://github.com/apache/iotdb-client-nodejs">apache/iotdb-client-nodejs</a>，npm 包名 <code>@iotdb/client</code>，版本号与数据库同步为 2.0.11。</p>
<p>从 <code>package.json</code> 和 README 看，能力包括树模型和表模型双 API、<code>SessionPool</code>（多节点轮询负载均衡与故障切换）、<code>TableSessionPool</code>（表模型专用，带 database 上下文管理）、SSL/TLS 支持和完整的 TypeScript 类型定义。</p>
<p>把这个和 V2.0.10 的 C 语言驱动 SDK 放在一起看，客户端覆盖的层次是：Java、Python、C++、C# 覆盖服务端和长期存在的集成场景，C 驱动覆盖边缘设备，Node.js 覆盖 Web 应用和脚本化数据处理。Node.js 客户端此前只能通过 REST 或 JDBC 桥接。</p>
<h3>其他客户端修复</h3>
<ul>
<li><a href="https://github.com/apache/iotdb/pull/18096">#18096</a>：C++ 客户端查询 DATE <code>1000-01-01</code> 崩溃</li>
<li><a href="https://github.com/apache/iotdb/pull/17759">#17759</a>：C++ 客户端把 FLOAT 推断列读成 DOUBLE</li>
<li><a href="https://github.com/apache/iotdb/pull/18005">#18005</a>：C++ 客户端 tablet 边界与会话关闭语义</li>
<li><a href="https://github.com/apache/iotdb/pull/18078">#18078</a>：JDBC 重连后复用失效的 statement id</li>
<li><a href="https://github.com/apache/iotdb/pull/17956">#17956</a>：Session C 增加 DATE/BLOB 支持与 RowRecord getter</li>
</ul>
<p><code>#18096</code> 是 <code>1000-01-01</code> 这个边界值触发的崩溃，属于只有真拿到这个值才会复现的问题。</p>
<hr />
<h2>变更七：中文 i18n</h2>
<p>这一项没有出现在 Release Notes 的功能列表里，但从代码量看是本周期最大的单项工程之一。</p>
<table>
<thead>
<tr>
<th>指标</th>
<th>V2.0.10</th>
<th>V2.0.11</th>
</tr>
</thead>
<tbody>
<tr>
<td>英文 i18n 消息键总数</td>
<td>5,178</td>
<td>9,413</td>
</tr>
<tr>
<td>i18n 目录新增和删除行</td>
<td>—</td>
<td>+17,036 / −1,815</td>
</tr>
</tbody>
</table>
<p>消息键数量增加了 82%。<code>DataNodeQueryMessages</code> 的中文版本周期新增 3,199 行、英文版新增 2,391 行，是改动量最大的两个文件。</p>
<p>关键动作是 <a href="https://github.com/apache/iotdb/pull/18110">#18110</a>（Complete zh locale i18n: convert leftover literals, review translations, add zh-compile CI），做了三件事：把残留的硬编码字面量转成消息键、复核现有翻译、新增 <code>zh-compile</code> CI。</p>
<p>第三件事影响最长远。i18n 消息键是 <code>public static final String</code> 常量，中英文两套文件必须逐一对应，少一个键就编译失败。新增的 <code>.github/workflows/zh-locale-compile.yml</code> 覆盖 <code>master</code>、<code>rel/*</code>、<code>rc/*</code> 分支的 push 和 PR。把中文 locale 的编译纳入 CI，等于用编译器保证新增的消息一定有中文翻译。</p>
<hr />
<h2>Release Notes 与代码不一致的几处</h2>
<p>逐条比对 Release Notes 和 diff 之后，有四处对不上。</p>
<h3>一、regionId 列表的语法归属</h3>
<p>Release Notes 写的是 EXTEND REGION 和 REMOVE REGION 支持 regionId 列表。但这两条语法在 v2.0.10 就已经支持了：</p>
<pre><code>v2.0.10 就已经是这样（IoTDBSqlParser.g4:587-593）
extendRegion
    : EXTEND REGION regionIds+=INTEGER_LITERAL (COMMA regionIds+=INTEGER_LITERAL)* TO targetDataNodeId=INTEGER_LITERAL
    ;
removeRegion
    : REMOVE REGION regionIds+=INTEGER_LITERAL (COMMA regionIds+=INTEGER_LITERAL)* FROM targetDataNodeId=INTEGER_LITERAL
    ;
</code></pre>
<p>本周期真正改的是 <code>MIGRATE REGION</code>：</p>
<pre><code>v2.0.10:  MIGRATE REGION regionId=INTEGER_VALUE FROM fromId=INTEGER_VALUE TO toId=INTEGER_VALUE
v2.0.11:  MIGRATE REGION regionIds+=INTEGER_VALUE (',' regionIds+=INTEGER_VALUE)* FROM fromId=INTEGER_VALUE TO toId=INTEGER_VALUE
</code></pre>
<p>对应 PR <a href="https://github.com/apache/iotdb/pull/18046">#18046</a>，标题是 Support multiple regions in MIGRATE REGION and multiple DataNodes in REMOVE DATANODE。Release Notes 把语句名写串了。</p>
<h3>二、两处命名变更未列入 Break change</h3>
<p>这是本周期风险最高的地方。有两个对外可见的名字改了，但 Break change 部分只提了 JDK 17。</p>
<p>SQL 关键字改名，来自 <a href="https://github.com/apache/iotdb/pull/17988">#17988</a>：</p>
<pre><code>SCHEMA_REGION_GROUP_NUM  -&gt;  MAX_SCHEMA_REGION_GROUP_NUM
DATA_REGION_GROUP_NUM    -&gt;  MAX_DATA_REGION_GROUP_NUM
</code></pre>
<p>三个语法文件（<code>IdentifierParser.g4</code>、<code>IoTDBSqlParser.g4</code>、<code>RelationalSql.g4</code>）里的词法记号都改了。</p>
<p>配置项改名，来自 <a href="https://github.com/apache/iotdb/pull/18138">#18138</a>：</p>
<pre><code>partition_table_recover_max_read_megabytes_per_second
  -&gt;  partition_table_recover_max_read_mb_per_sec
</code></pre>
<p>影响面是写死了 <code>WITH (SCHEMA_REGION_GROUP_NUM = N)</code> 的建库脚本、在 conf 里配了旧配置项的集群，以及自动化运维平台里硬编码这些标识符的模板。改名本身有理由：<code>MAX_</code> 前缀让语义更准确，<code>mb_per_sec</code> 和别的配置项命名风格更一致。但这对存量脚本是硬断裂，本该和 JDK 17 一起列进 Break change。</p>
<h3>三、Bugs 列表与 2.0.10 有重叠</h3>
<p>2.0.11 的 Bugs 列表里有些条目在 2.0.10 分支上已经修过。原因在发布分支的结构上：两个 tag 的 merge-base 是 <code>7e488ffcac</code>（2026-05-28），<code>rc/2.0.10</code> 和 <code>rc/2.0.11</code> 是从 master 不同位置切出来的两条独立维护线，同一批修复会被 cherry-pick 到两条线上，只是 commit hash 不同。</p>
<p>比如 <code>#17583</code>（LIST USER 并发修复）在两个 tag 上都能找到。所以在 2.0.11 的 Bugs 列表里看到某个 bug，不代表它是 2.0.11 才修的。判断某个修复实际进入了哪个版本，可靠的方法是：</p>
<pre><code>git log v2.0.10 --oneline --grep="#&lt;PR号&gt;"    # 有输出 = 2.0.10 已含
git log v2.0.11 --oneline --grep="#&lt;PR号&gt;"    # 有输出 = 2.0.11 已含
</code></pre>
<p>本文的版本归属判断都用了这个方法。</p>
<h3>四、COPY TO 的改动</h3>
<p>Release Notes 写的是支持用 SQL 把查询结果写到指定路径的 TsFile。但 <code>COPY ... TO '&lt;path&gt;'</code> 的语法在两个 tag 之间逐字未变。</p>
<p>本周期 copyto 相关的实际改动只有 3 个文件、54 行增量，核心是 <code>CopyToTsFileOptions</code> 新增了一个字段：</p>
<pre><code>private boolean generateNewTableName = false;
</code></pre>
<p>逻辑是当查询里识别不出唯一的目标表时（<code>onlyOneQueriedTable == null</code>），把表名标上 <code>AUTO_GEN_MARK</code> 写入 TsFile 元数据：</p>
<pre><code>if (onlyOneQueriedTable == null) {
    targetTableName = DEFAULT_TABLE_NAME;
    generateNewTableName = true;
} else {
    targetTableName = onlyOneQueriedTable.getTableName();
}
</code></pre>
<p>这个功能本身早已存在，本周期只是让无明确来源表的导出结果在元数据里标注得更准确。</p>
<hr />
<h2>问题修复</h2>
<p>305 个 commit 里有 172 个（56%）标题含 fix。以下几类影响面较大。</p>
<h3>内存与资源</h3>
<ul>
<li>ConfigNode 线程泄漏：IoTV2 3C3D 三副本下跑树模型 SQL 用例，<code>ConfigNodeRPC-Processor</code> 线程数涨到 3,000，集群无法连接，CN 和 DN 都报 NPE</li>
<li><code>PipeTsFileEpochProgressIndexKeeper</code> 保留超过 50,000 个 TsFileResource：2 副本边读边写边删、停掉一个 DataNode，54 小时后 OOM，产生 23 GB dump（<code>ON_HEAP_MEMORY="20G"</code>）</li>
<li>IoTConsensus 进程退出：3C3D 2 副本并发读写删加停一个 DataNode，单 DN 进程退出，25 GB dump</li>
</ul>
<p>后两条出现在同一个测试场景里，指向的是系统性的内存问题。这类问题需要长时间破坏性压测才能暴露。</p>
<h3>查询</h3>
<ul>
<li><code>Frame size (69670459) larger than protect max size (67108864)</code> 导致查询挂起。超限是预期内的情况，应该返回明确错误</li>
<li>整型和浮点型在过滤条件中比较行为不一致（树模型和表模型）</li>
<li><code>CAST(1.1 AS FLOAT)</code> 抛 <code>UnsupportedOperationException: DoubleColumn</code></li>
<li>时间过滤下对齐 LAST 查询挂起（<a href="https://github.com/apache/iotdb/pull/18213">#18213</a>）</li>
<li>窗口函数状态跨批次重置（<a href="https://github.com/apache/iotdb/pull/17813">#17813</a>）</li>
<li>Driver Scheduler 就绪队列预留泄漏（<a href="https://github.com/apache/iotdb/pull/17919">#17919</a>）</li>
</ul>
<h3>集群与共识</h3>
<ul>
<li><code>LIST USER</code>、<code>CREATE USER</code>、<code>DROP USER</code> 并发执行返回 <code>301: Ratis request failed Unknown</code>，CN 日志报 <code>ConcurrentModificationException</code></li>
<li>重启后某节点停在 Unknown 状态且无日志，主线程被阻塞，但该节点仍能正常做 compaction</li>
<li><code>SHOW REGIONS</code> 中 <code>CompressionRatio</code> 在缩容期间和重启后显示负数或 NaN</li>
<li><code>LOAD TSFILE</code> 在接收端有写权限时仍报权限失败，且数据未同步</li>
<li>缩容时监控面板上 IoTConsensusQueue 的内存显示负值</li>
</ul>
<p>第二条里节点仍能正常 compaction 这一点，说明用单一功能是否正常来判断节点健康不可靠。</p>
<h3>同步与存储</h3>
<ul>
<li><code>attribute</code> 字段 null 值导致接收端数组越界，阻塞整条同步管道</li>
<li>空值插入字段的行无法同步到接收端</li>
<li>TTL 过期数据的幂等逻辑错误导致重复同步</li>
<li>单个 Pipe 子任务内存不足触发同步临时停止</li>
<li>修改 write-back-sink 的用户名或密码后阻止数据接收</li>
<li>加载操作异常重复广播删除标记</li>
<li>Schema 快照导致的表设备恢复问题（<a href="https://github.com/apache/iotdb/pull/18324">#18324</a>）</li>
</ul>
<h3>其他修复</h3>
<ul>
<li><a href="https://github.com/apache/iotdb/pull/18239">#18239</a>：DataNode 启用 CRC32 硬件指令</li>
<li><a href="https://github.com/apache/iotdb/pull/18045">#18045</a>：compaction 硬链接失败时回退为复制</li>
<li><a href="https://github.com/apache/iotdb/pull/18223">#18223</a>：修复 <code>TierManager</code> 目录重置时的并发访问</li>
<li><a href="https://github.com/apache/iotdb/pull/18290">#18290</a>：修复 IoTConsensus 配置的并发访问</li>
<li><a href="https://github.com/apache/iotdb/pull/18304">#18304</a>：新增 <code>CorruptedTsFileException</code>，异常里带上文件路径</li>
</ul>
<hr />
<h2>升级注意事项</h2>
<h3>前提：JDK 17</h3>
<p>这是本版本唯一的硬性阻断项。仍然运行 JDK 8 或 11 的节点必须先升级 JVM，再升级 IoTDB。</p>
<pre><code>java -version
grep -r "JAVA_HOME" $IOTDB_HOME/conf/*.sh
</code></pre>
<p>跨 JDK 基线升级建议分两步走，先把当前版本（比如 2.0.10）在 JDK 17 上跑通，隔离掉 JDK 升级带来的问题，再升级到 2.0.11。</p>
<p>另外两点需要单独确认：</p>
<ul>
<li>自定义 UDF 和插件是通过 jar 加载的用户代码，需要自行确认 JDK 17 兼容性</li>
<li>如果有基于 IoTDB REST 接口的服务端扩展，注意 javax 到 jakarta 是包名断裂，不是版本升级。原来 <code>import javax.ws.rs.GET;</code> 的代码在新版本下是找不到类，不是 deprecated 警告，需要重新编译</li>
</ul>
<h3>两处静默改名</h3>
<p>旧名字不会报错，只会静默失效，这是最需要检查的地方。</p>
<pre><code># 建库脚本里的旧 SQL 关键字
grep -rnE "SCHEMA_REGION_GROUP_NUM|DATA_REGION_GROUP_NUM" --include="*.sql" --include="*.sh" .

# conf 里的旧配置项
grep -rn "partition_table_recover_max_read_megabytes_per_second" $IOTDB_HOME/conf/
</code></pre>
<h3>用 SQL 改配置</h3>
<p>conf 文件不是唯一的入口。IoTDB 提供 SET CONFIGURATION 语句：</p>
<pre><code>SET CONFIGURATION "heartbeat_interval_in_ms"="500";
SET CONFIGURATION "enable_seq_space_compaction"="false";
SET CONFIGURATION "enable_unseq_space_compaction"="false" ON 0;   -- 只改 0 号节点
</code></pre>
<p>配置模板里每个条目都标了 effectiveMode，决定了它能不能这样改：</p>
<pre><code>122 项  hot_reload   可以改，立即生效
197 项  restart      可以改，写回文件，重启后生效
 27 项  first_start  只在首次启动时读取，改不了
</code></pre>
<p>SET CONFIGURATION 会拒绝两类键：模板里不存在的（写错了会当场报出来），以及 first_start
的。剩下的都会被接受并写回 iotdb-system.properties，所以重启后依然有效，不需要手工编辑
文件。模板头部就是这么建议的：</p>
<pre><code># Manually modifying configuration file is not recommended, which may cause node restart fail.
# If you need to modify the cluster name, it's recommended to use 'set configuration "cluster_name=xxx"' sql.
</code></pre>
<p>改完用 SHOW CONFIGURATION 确认生效值。注意它显示的是运行时实际生效的值，而不是文件里的
原始值（这个区分本身是 2.0.11 才修对的，见 <a href="https://github.com/apache/iotdb/pull/18108">#18108</a>）：</p>
<pre><code>SHOW CONFIGURATION;
SHOW CONFIGURATION ON 0;
</code></pre>
<p>对升级来说，这意味着 conf 合并的工作量可以小很多：只有 restart 和 first_start 的项必须
落到文件里，hot_reload 的项升级后执行一条 SQL 就行。</p>
<h3>升级步骤</h3>
<p>备份程序目录，替换，改配置，启动。data 目录原地不动。</p>
<pre><code># 1. 记录当前版本
./sbin/start-cli.sh -e "show version"

# 2. 备份程序目录（不含 data，加起来几百 MB）
BK=/opt/iotdb.backup.$(date +%Y%m%d)
mkdir -p $BK
cd $IOTDB_HOME
cp -r lib sbin conf tools $BK/

# 3. 替换。必须先删除再拷贝
cd $IOTDB_HOME
rm -rf lib sbin conf tools
cp -r apache-iotdb-2.0.11-all-bin/lib   ./lib
cp -r apache-iotdb-2.0.11-all-bin/sbin  ./sbin
cp -r apache-iotdb-2.0.11-all-bin/conf  ./conf
cp -r apache-iotdb-2.0.11-all-bin/tools ./tools

# 4. 把备份里改过的配置项改回新 conf
diff $BK/conf/iotdb-system.properties conf/iotdb-system.properties

# 5. 启动并验证
./sbin/start-standalone.sh            # 分布式则分别启 confignode 和 datanode
./sbin/start-cli.sh -e "show version"
</code></pre>
<p>第 3 步必须先删除再拷贝。lib 里的 jar 文件名带版本号，2.0.11 有 43 个 jar 改了名，cp 只覆盖
同名文件，旧 jar 会全部留下。而启动脚本把 lib 下所有 jar 都收进 classpath：</p>
<pre><code>CLASSPATH=""
for f in "${IOTDB_HOME}"/lib/*.jar; do
  CLASSPATH=${CLASSPATH}":"$f
done
</code></pre>
<p>glob 按文件名排序展开，旧版本号（2.0.10、0.14.1、3.2.2）恰好排在新版本号（2.0.11、0.23.0、
3.3.0）前面，而 classpath 里先出现的优先。结果是 lib 从 114 个 jar 变成 157 个，新 jar 明明
在目录里却不会被加载：升级看起来成功，show version 也查得到 2.0.11，但跑的是 2.0.10 的代码。</p>
<p>sbin 和 tools 下的脚本名是固定的，conf 也是固定文件名，本来不删也能覆盖；统一删掉只是让
流程一致，免得以后哪次改版又出现改名。</p>
<p>备份只覆盖这四个目录。不要连 data 一起备份：生产环境的数据动辄上 TB，复制一份要等量磁盘
和数小时，很可能在升级前先把磁盘写满。这次升级也不修改 data 目录，新版本只是读它。</p>
<h3>回退</h3>
<p>把四个目录换回去，然后启动：</p>
<pre><code>cd $IOTDB_HOME
rm -rf lib sbin conf tools
BK=/opt/iotdb.backup.20260914
cp -r $BK/lib ./lib
cp -r $BK/sbin ./sbin
cp -r $BK/conf ./conf
cp -r $BK/tools ./tools
./sbin/start-standalone.sh
</code></pre>
<p>前提是回退前新版本没有写过数据。本周期 TsFile 从 2.3.1 升到了 2.4.0，用旧版本打开新版本
写过的数据目录通常不可行。如果新版本已经写入，回退要先处理这份数据，这一步没有通用的解法。</p>
<h3>各场景的注意事项</h3>
<ul>
<li>使用 Pipe 同步：升级后在接收端做一次同步验证，确认跨版本协议兼容</li>
<li>使用 C++ 客户端：本周期改为默认 OpenSSL 3.x，客户端需要同步升级</li>
<li>使用 AINode：本周期没有 AI 侧变更，无需跟进</li>
<li>边缘场景：IoTDB Edge 第一版，后续版本会继续演进架构</li>
</ul>
<hr />
<h2>参考资料</h2>
<ul>
<li><a href="https://dlcdn.apache.org/iotdb/2.0.11/RELEASE_NOTES.md">Apache IoTDB 2.0.11 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/compare/v2.0.10...v2.0.11">V2.0.10 → V2.0.11 完整 Changelog</a>（305 commits）</li>
<li><a href="https://github.com/apache/iotdb/pull/17859">JDK 17 与 Jakarta 迁移 PR #17859</a></li>
<li><a href="https://github.com/apache/iotdb/pull/18538">IoTDB Edge 单 JVM 合并 PR #18538</a></li>
<li><a href="https://github.com/apache/iotdb/commit/d02e6af593a0daf2b1f92f6074b5138d63771e34">元数据租约自隔离框架 commit d02e6af5</a></li>
<li><a href="https://github.com/apache/iotdb/pull/18425">Authority 模块高可用 PR #18425</a></li>
<li><a href="https://github.com/apache/iotdb/pull/17975">集群运行时配置热加载 PR #17975</a></li>
<li><a href="https://github.com/apache/iotdb/pull/18026">Thrift 客户端双向 TLS PR #18026</a></li>
<li><a href="https://github.com/apache/iotdb/pull/18110">中文 i18n 与 zh-compile CI PR #18110</a></li>
<li><a href="https://github.com/apache/iotdb-client-nodejs">Node.js 客户端仓库 apache/iotdb-client-nodejs</a></li>
<li><a href="https://iotdb.apache.org/Download/">IoTDB 官网下载页</a></li>
</ul>
<h3>站内相关</h3>
<ul>
<li><a href="/posts/iotdb-jdk17-jakarta-migration-preview/">Apache IoTDB 将最低 JDK 提升至 17 并完成 javax → jakarta 迁移</a></li>
<li><a href="/posts/iotdb-v2010-release-notes/">Apache IoTDB V2.0.10 版本解析</a></li>
<li><a href="/posts/iotdb-v208-release-notes/">Apache IoTDB V2.0.8 版本解析</a></li>
<li><a href="/posts/iotdb-migration-13-to-2x/">Apache IoTDB 从 1.3.x 迁移到 2.x 完整指南</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB V2.0.10 版本解析：SQL 能力跃进与 C 语言生态启航]]></title>
            <link>https://critas.wang/posts/iotdb-v2010-release-notes/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-v2010-release-notes/</guid>
            <pubDate>Thu, 09 Jul 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB V2.0.10 深度解析，跳过 2.0.9 的双版本合并发布。涵盖 CTE/集合操作/SQL 增强、C 语言驱动 SDK、Toto/Moirai2 双模型集成、IoTConsensus 多目录快照等架构决策的源码级分析。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>Apache IoTDB V2.0.10 于 2026-07-09 正式发布。这次发布有些特殊——<strong>社区跳过了 V2.0.9</strong>，将两个版本的工作合并发布。</p>
<p>跳过版本的原因在邮件列表中由 Yuan Tian 做了说明：原计划纳入 2.0.9 的一个 release-note 项在持续迭代中超出了预期周期，等到它开发完成时，2.0.10 规划的工作也已经就绪。单独发布 2.0.9 的实际价值有限，因此社区决定将相关变更统一纳入 2.0.10。</p>
<p>如果 V2.0.7 的主题是"安全加固"，V2.0.8 的主题是"AI 增强"，那么 V2.0.10 的主题可以概括为：<strong>SQL 能力跃进与 C 语言生态启航</strong>。从 V2.0.8 到 V2.0.10，共计 <strong>407 个 commit</strong>（<code>git rev-list --count v2.0.8..v2.0.10</code>）。作为参照，V2.0.7 → V2.0.8 周期为 638 个 commit——虽然本次合并了两个版本号的规划，但绝对工作量仍在常规周期水平，跳版本更多是发布节奏的调整而非工作量翻倍。</p>
<p>本文从以下几个维度进行源码级解读：</p>
<ol>
<li><strong>SQL 能力大跃进</strong> — CTE、集合操作、IF 函数、APPROX_PERCENTILE、DEBUG SQL</li>
<li><strong>C 语言驱动 SDK</strong> — Session C 接口的设计与实现</li>
<li><strong>AI 模型矩阵扩展</strong> — Toto、Moirai2 双模型集成与架构升级</li>
<li><strong>IoTConsensus 多目录快照</strong> — 存储层的架构演进</li>
<li><strong>系统管理能力增强</strong> — 手动负载均衡、RemoveDataNode 进度、SHOW CONFIGURATION</li>
<li><strong>Pipe 持续深耕</strong> — 109 个 commit 的同步引擎打磨</li>
<li><strong>隐藏在 commit log 中的重要变更</strong></li>
<li><strong>生产环境升级建议</strong></li>
</ol>
<blockquote>
<p>本文内容参考了 <a href="https://dlcdn.apache.org/iotdb/2.0.10/RELEASE_NOTES.md">Apache IoTDB 2.0.10 Release Notes</a>、邮件列表讨论以及 <a href="https://github.com/apache/iotdb/compare/v2.0.8...v2.0.10">v2.0.8...v2.0.10 的 407 个 commit</a>。</p>
</blockquote>
<hr />
<h2>变更一：SQL 能力大跃进</h2>
<p>V2.0.10 在 SQL 查询层面带来了多项重量级增强，让 IoTDB 的表模型在分析场景下更加得心应手。</p>
<h3>1.1 集合操作：UNION / INTERSECT / EXCEPT</h3>
<p>集合操作是 SQL 标准中的核心能力。V2.0.10 在表模型中支持了 <code>UNION</code>、<code>INTERSECT</code> 和 <code>EXCEPT</code> 三种集合运算。</p>
<pre><code>┌────────────────────────────────────────────────────┐
│              UNION (并集)                           │
│  查询结果A + 查询结果B，自动去重                     │
├────────────────────────────────────────────────────┤
│           INTERSECT (交集)                          │
│  同时出现在A和B中的行                               │
├────────────────────────────────────────────────────┤
│            EXCEPT (差集)                            │
│  出现在A中但不在B中的行                             │
└────────────────────────────────────────────────────┘
</code></pre>
<p>在时序场景中，集合操作的实用性很高。例如：找出同时在温度异常设备和压力异常设备列表中的传感器；或者对比两个时间段内活跃设备的差异。</p>
<pre><code>-- 查询两个时间段内都出现异常的设备（交集）
SELECT device_id FROM table1 WHERE temperature &gt; 100 AND time &gt;= '2026-07-01'
INTERSECT
SELECT device_id FROM table1 WHERE temperature &gt; 100 AND time &gt;= '2026-07-02';

-- 找出新增的异常设备（差集）
SELECT device_id FROM table1 WHERE temperature &gt; 100 AND time &gt;= '2026-07-02'
EXCEPT
SELECT device_id FROM table1 WHERE temperature &gt; 100 AND time &gt;= '2026-07-01';
</code></pre>
<p>从源码层面看，这次"新增"有一个有趣的细节：<strong>集合操作的完整实现在 v2.0.8 的代码里就已经存在</strong>。对比 v2.0.8 和 v2.0.10 两个 tag：</p>
<ul>
<li><code>RelationalSql.g4</code> 语法文件中 <code>UNION | INTERSECT | EXCEPT</code> 的产生式在 v2.0.8 已完整定义</li>
<li><code>UnionNode</code> / <code>IntersectNode</code> / <code>ExceptNode</code> 三个 PlanNode 及 <code>SetOperationNodeTranslator</code> 优化规则在 v2.0.8 源码树中已就位</li>
<li><code>StatementAnalyzer.visitSetOperation</code> 和 <code>RelationPlanner.visitUnion/visitIntersect/visitExcept</code> 的分析与规划逻辑同样早已实现</li>
</ul>
<p>也就是说，这套能力是在 2.0.8 周期就埋进了代码，经过一个版本周期的稳定化后，在 2.0.10 才正式官宣 GA。这符合 IoTDB 社区对未成熟功能"先禁用、后开放"的做法——2.0.8 周期就有过 <a href="https://github.com/apache/iotdb/pull/17373">#17373</a>（Disabled some unstable function）这样的先例。对读 Release Notes 的用户来说这是"新功能"，对读源码的人来说这是"解禁"。</p>
<h3>1.2 CTE（Common Table Expressions）</h3>
<p>CTE 是复杂查询的基石。通过 <code>WITH</code> 子句将子查询定义为临时命名结果集，后续在同一个查询中多次引用，大幅提升 SQL 的可读性和可维护性。</p>
<pre><code>-- 使用 CTE 构建分层查询
WITH 
  abnormal_temp AS (
    SELECT device_id, time, temperature 
    FROM factory.sensors 
    WHERE temperature &gt; 100 AND time &gt;= '2026-07-01'
  ),
  abnormal_pressure AS (
    SELECT device_id, time, pressure 
    FROM factory.sensors 
    WHERE pressure &gt; 200 AND time &gt;= '2026-07-01'
  )
SELECT a.device_id, a.time, a.temperature, b.pressure
FROM abnormal_temp a
JOIN abnormal_pressure b 
  ON a.device_id = b.device_id AND a.time = b.time;
</code></pre>
<p>与集合操作类似，CTE 的语法定义（<code>WITH RECURSIVE? namedQuery ...</code>）和 <code>StatementAnalyzer.analyzeWith</code> 分析逻辑在 v2.0.8 源码中就已完整存在，2.0.10 是稳定化后的正式官宣。需要注意的是，<strong>递归 CTE 目前仍未开放</strong>——源码中 <code>analyzeWith</code> 对 <code>RECURSIVE</code> 关键字会抛出 <code>"recursive cte is not supported yet."</code>，当前支持的是标准的非递归 CTE。</p>
<p>2.0.10 周期中 CTE 相关的直接改动是 <a href="https://github.com/apache/iotdb/pull/17473">#17473</a>，它修复的是集成测试 <code>IoTDBCteIT#testConcurrentCteQueries</code> 的内存问题，说明社区在官宣前对 CTE 做了并发场景的验证。</p>
<h3>1.3 新增函数：IF、APPROX_PERCENTILE、二进制函数</h3>
<p><strong>IF 标量函数</strong>提供了条件表达式能力：</p>
<pre><code>-- 根据温度分级标记
SELECT time, device_id, 
       IF(temperature &gt; 100, 'HIGH', 'NORMAL') AS temp_level
FROM factory.sensors;
</code></pre>
<p><strong>APPROX_PERCENTILE 聚合函数</strong>使用近似算法计算百分位数，在大数据量场景下比精确计算快 10-100 倍：</p>
<pre><code>-- 近似计算 P95 延迟
SELECT APPROX_PERCENTILE(latency, 0.95) FROM server.metrics 
WHERE time &gt;= '2026-07-01';
</code></pre>
<p>commit <a href="https://github.com/apache/iotdb/pull/17368">#17368</a> 为 APPROX_PERCENTILE 增加了严格的权重校验和完善的错误处理，确保在大规模数据下的准确性。</p>
<p><strong>二进制函数</strong>方面，提供了 <code>from_base64</code> 和 <code>from_base32</code> 等解码函数，commit <a href="https://github.com/apache/iotdb/pull/17466">#17466</a> 修复了边界情况下的问题。</p>
<p>顺带一提，这三类函数与集合操作/CTE 情况相同——<code>IF</code> 的解析逻辑、<code>approx_percentile</code> 的函数注册、base64/base32 函数及其测试在 v2.0.8 源码中均已存在，2.0.10 是在打磨（#17368 的权重校验、#17466 的边界修复）之后正式将它们纳入发布口径。</p>
<h3>1.4 DEBUG SQL 与 Explain Analyze 优化</h3>
<p>V2.0.10 新增了 <strong>DEBUG SQL</strong> 能力，允许用户在查询时获取更详细的诊断信息。feature commit 是 <a href="https://github.com/apache/iotdb/pull/17178">#17178</a>（Support debug for query），语法层面的改动很轻：<code>RelationalSql.g4</code> 的顶层规则从 <code>statement EOF</code> 变为 <code>DEBUG? statement EOF</code>——在任意语句前加 <code>DEBUG</code> 前缀即可开启。同时优化了 <code>Explain Analyze</code> 的结果集展示，并且 EXPLAIN / EXPLAIN ANALYZE 现在也支持作用于 <code>EXECUTE</code> 预编译语句（<a href="https://github.com/apache/iotdb/pull/17318">#17318</a>）。</p>
<p>commit <a href="https://github.com/apache/iotdb/pull/17454">#17454</a> 修复了 Explain Analyze 中算子信息清理逻辑的缺陷——在打印执行计划时，某个算子的特定信息没有被正确清除，导致结果展示不准确。这个修复确保了运维人员在分析查询性能时看到的数据是可信的。</p>
<h3>1.5 Schema 级和表级存储空间统计</h3>
<p>新增了 schema-level 和 table-level 的存储空间统计能力。主体实现是 <a href="https://github.com/apache/iotdb/pull/17169">#17169</a>（Implement table &amp; tree disk usage statistics），<a href="https://github.com/apache/iotdb/pull/17768">#17768</a> 在此基础上为表磁盘使用量补充了 <code>table type</code> 维度。树模型侧对应新增了 <code>SHOW DISK USAGE</code> 语句（<code>IoTDBSqlParser.g4</code> 中新增 <code>showDiskUsage</code> 规则）。</p>
<p>这是数据库可观测性的重要拼图——运维人员可以在 schema/table 粒度上精确了解存储分布，而不再只能看到 DataNode 级别的粗粒度统计。</p>
<h3>1.6 SHOW QUERIES 增强</h3>
<p><code>SHOW QUERIES</code> 命令新增了三列：</p>
<ul>
<li><strong>Client IP</strong>：发起查询的客户端 IP</li>
<li><strong>Timeout Threshold</strong>：查询的超时阈值</li>
<li><strong>Total Request Waiting Latency</strong>：请求在队列中的总等待延迟</li>
</ul>
<p>这三列信息对于诊断慢查询和定位问题客户端至关重要。feature commit 是 <a href="https://github.com/apache/iotdb/pull/17350">#17350</a>（Add extra client_ip and timeout columns for show queries）。配套地，commit <a href="https://github.com/apache/iotdb/pull/17505">#17505</a> 修复了 SHOW QUERIES 中 <code>highestPriority</code> 设置不正确的问题，而 <a href="https://github.com/apache/iotdb/pull/17507">#17507</a> 甚至让 SHOW QUERIES 在可用内存不足时也能立即执行——因为运维诊断命令不应该因为业务负载高而被阻塞。</p>
<hr />
<h2>变更二：C 语言驱动 SDK — 嵌入式生态的敲门砖</h2>
<h3>2.1 背景与动机</h3>
<p>在工业物联网和嵌入式场景中，C 语言仍然是王者。PLC、RTU、边缘网关等设备上运行的软件大多以 C 编写。V2.0.10 之前，IoTDB 提供了 Java、Python、C++、C#、Go 等语言的客户端，但缺少标准 C 接口。</p>
<p>commit <a href="https://github.com/apache/iotdb/pull/17347">#17347</a>（Session C Interface，由 Hongzhi Gao 实现）填补了这个空白。</p>
<h3>2.2 源码架构分析</h3>
<p>从源码看，C 接口并不是一个独立的 <code>client-c</code> 模块，而是<strong>在 C++ 客户端之上封装的一层 C ABI wrapper</strong>——这是一个务实的设计选择，复用了 C++ 客户端已有的 Thrift RPC、TsBlock 编解码和重连逻辑：</p>
<pre><code>iotdb-client/client-cpp/
  src/include/SessionC.h        ← C 接口头文件（纯 C 声明）
  src/session/SessionC.cpp      ← C wrapper 实现（内部调 C++ Session）
  examples/tree_example.c       ← 树模型 C 示例
  examples/table_example.c      ← 表模型 C 示例
  test/cpp/sessionCIT.cpp       ← C 接口集成测试
  test/cpp/sessionCRelationalIT.cpp
</code></pre>
<p>所有 API 以 <code>ts_</code> 为前缀，分为树模型（<code>ts_session_*</code>）和表模型（<code>ts_table_session_*</code>）两套句柄。核心能力包括：</p>
<table>
<thead>
<tr>
<th>能力</th>
<th>对应 API</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>类型化参数传值写入</strong></td>
<td><code>ts_session_insert_record</code> / <code>ts_session_insert_tablet</code> 等，按数据类型绑定值而非拼接 SQL 字符串</td>
</tr>
<tr>
<td><strong>多节点故障切换</strong></td>
<td><code>ts_session_new_multi_node(nodeUrls, urlCount, ...)</code></td>
</tr>
<tr>
<td><strong>多种数据类型支持</strong></td>
<td>INT32/INT64/FLOAT/DOUBLE/TEXT/BOOLEAN/DATE/BLOB</td>
</tr>
<tr>
<td><strong>统一错误处理</strong></td>
<td><code>TsStatus</code> 返回码 + <code>ts_get_last_error()</code></td>
</tr>
</tbody>
</table>
<p>需要说明的是，Release Notes 里的"参数绑定（parameter binding）"指的是上表第一行——<strong>类型化的值绑定写入接口</strong>（区别于把值拼进 SQL 字符串），而不是 ODBC 风格的 <code>?</code> 占位符预编译。翻遍 <code>SessionC.h</code> 的符号表，目前没有 prepare/bind 类 API；占位符式的 PreparedStatement 这个版本落在了 JDBC 侧（见 7.1 节）。</p>
<p>真实的 C API 用法（摘自源码 <code>examples/tree_example.c</code>）：</p>
<pre><code>CSession* session = ts_session_new(HOST, PORT, USER, PASS);
if (ts_session_open(session) != TS_OK) { /* 错误处理 */ }

// 类型化写入：measurements/values 按类型传入，无需拼 SQL
ts_session_insert_record_str(session, DEVICE, 1LL, 1, measurements, values);

// 查询
CSessionDataSet* dataSet;
ts_session_execute_query(session, "select s0 from root.cdemo.d0", &amp;dataSet);
</code></pre>
<p>commit <a href="https://github.com/apache/iotdb/pull/17956">#17956</a> 进一步为 Session C 增加了 DATE/BLOB 类型支持和 RowRecord getter 方法，完善了类型体系。</p>
<h3>2.3 多节点故障切换机制</h3>
<p>故障切换是生产环境的关键需求。通过 <code>ts_session_new_multi_node()</code> 传入节点 URL 列表后，C 驱动内置了多节点切换逻辑：</p>
<pre><code>┌─────────────────────────────────────────────┐
│           C 客户端故障切换流程                │
│                                             │
│  连接 DataNode 1 ──▶ 失败 ──▶ DataNode 2   │
│                              │             │
│                         成功/失败           │
│                              │             │
│              ┌───────────────┼───────┐     │
│              │               │       │     │
│          成功建立连接    失败     失败     │
│              │          重试DN3  重试DN4  │
│              ▼               │       │     │
│          返回Session      最终失败 最终失败 │
└─────────────────────────────────────────────┘
</code></pre>
<p>需要注意的是，当前的 failover 机制依赖于客户端侧的节点列表配置，在服务端滚动升级或扩容场景下需要配套的节点发现策略。</p>
<hr />
<h2>变更三：AI 模型矩阵扩展 — Toto 与 Moirai2 双模型集成</h2>
<h3>3.1 模型全景</h3>
<p>V2.0.8 引入了 Chronos-2（Amazon 的时序基础模型）。V2.0.10 进一步扩展，Release Notes 官宣了两款新模型：</p>
<table>
<thead>
<tr>
<th>模型</th>
<th>来源</th>
<th>定位</th>
<th>对比 Chronos-2</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Toto</strong></td>
<td>Datadog 开源</td>
<td>面向可观测性场景的 Transformer 时序模型</td>
<td>更轻量，适合运维监控</td>
</tr>
<tr>
<td><strong>Moirai2</strong></td>
<td>Salesforce 开源</td>
<td>统一时序预测框架</td>
<td>支持多变量联合预测</td>
</tr>
</tbody>
</table>
<p>commit <a href="https://github.com/apache/iotdb/pull/17322">#17322</a> 和 <a href="https://github.com/apache/iotdb/pull/17056">#17056</a> 分别引入了 Toto 和 Moirai2。</p>
<p>有趣的是，commit log 里还藏着<strong>第三个未官宣的模型</strong>：<a href="https://github.com/apache/iotdb/pull/17386">#17386</a> 集成了 CMU 的 <strong>MOMENT</strong>（<code>[AINode] Integrate MOMENT as a builtin forecasting model</code>）。它没有出现在 Release Notes 中，可能仍处于打磨阶段——但代码已经合入 2.0.10，感兴趣的用户可以自行尝试。</p>
<p>更值得关注的是，V2.0.10 对 AINode 的架构进行了几项升级：</p>
<h3>3.2 同模型类型多模型管理</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17299">#17299</a> 让 AINode 可以在同一个 <code>model_type</code> 下管理多个模型。这意味着：</p>
<pre><code>V2.0.8:
  model_type: forecasting → [Chronos-2]  // 一对一

V2.0.10:
  model_type: forecasting → [Chronos-2, Toto, Moirai2]  // 一对多
  可以按场景选择不同的模型进行推理
</code></pre>
<p>commit <a href="https://github.com/apache/iotdb/pull/17334">#17334</a> 更进一步，支持了 HubMixin 模型（HuggingFace Hub 上的模型），并修改了推理流水线，为后续接入更多开源模型铺平了道路。</p>
<h3>3.3 CPU 推理与进程隔离</h3>
<p>需要先澄清一个容易误读的点：从源码看，CPU 推理后端（<code>device/backend/cpu_backend.py</code>）和推理进程池（<code>pool_controller.py</code>）的基础设施<strong>在 v2.0.8 就已存在</strong>。V2.0.10 的实际工作是让新增的内置模型（Toto/Moirai2/MOMENT）能够以 CPU 后端在隔离的推理进程中加载运行——<a href="https://github.com/apache/iotdb/pull/17299">#17299</a> 重构了 <code>pool_controller.py</code> 的模型加载逻辑，<a href="https://github.com/apache/iotdb/pull/17314">#17314</a> 修复了推理后端的自动选择。</p>
<pre><code>┌─────────────────────────────────────────────────┐
│           AINode 多模型推理架构                    │
│                                                  │
│  ┌──────────────────────────────────────┐       │
│  │ AINode                               │       │
│  │  ├─ Inference Proc 1 (CPU/GPU)       │       │
│  │  ├─ Inference Proc 2 (CPU/GPU)       │       │
│  │  └─ Inference Proc N                 │       │
│  │     隔离推理进程，单个模型崩溃        │       │
│  │     不影响其他推理任务                │       │
│  └──────────────────────────────────────┘       │
└─────────────────────────────────────────────────┘
</code></pre>
<p>进程隔离的意义在于：当某个模型（如 Toto）因为输入数据异常而崩溃时，不会影响 Chronos-2 的推理任务。这对于生产环境的多模型并行推理至关重要。</p>
<p>另外，Release Notes 中"非 root 用户无法停止 AINode 进程"的修复，对应的源码改动落在 <a href="https://github.com/apache/iotdb/pull/17138">#17138</a>（Support register as system service）——整个周期内唯一改动 <code>stop-ainode.sh</code> 的 commit。它改造了 <code>start/stop-ainode.sh</code> 及 daemon 脚本（<code>kill -s TERM -- "-$PID"</code> 按进程组终止，恰好与隔离推理子进程的清理相呼应），让 AINode 可以注册为系统服务。</p>
<h3>3.4 推理后端的自动选择</h3>
<p>上面提到的 <a href="https://github.com/apache/iotdb/pull/17314">#17314</a> 让 AINode 能够根据模型类型和硬件环境自动选择最合适的推理后端（PyTorch CPU/GPU/CUDA），减少了手动配置的复杂度。配套的 <a href="https://github.com/apache/iotdb/pull/17323">#17323</a> 升级了 torch 版本以支撑新模型。</p>
<hr />
<h2>变更四：IoTConsensus 多目录快照 — 存储架构演进</h2>
<h3>4.1 变更前的限制</h3>
<p>在 V2.0.10 之前，IoTConsensus 协议的快照（Snapshot）只能存储到单一目录。在多磁盘部署场景中，这意味着：</p>
<ul>
<li>Snapshot 受限于单磁盘容量</li>
<li>无法利用多磁盘的并行 I/O 带宽</li>
<li>快照接收端的所有数据必须落在一个挂载点上</li>
</ul>
<h3>4.2 多目录快照方案</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/16811">#16811</a>（IoTConsensus Snap Multi Dir）实现了多目录快照支持。</p>
<p>核心设计思路：</p>
<ol>
<li><strong>FolderManager 下沉</strong>：将 <code>FolderManager</code> 从 DataNode 模块提取到 <code>node-commons</code>，使其可供 IoTConsensus 复用</li>
<li><strong>多目录策略</strong>：快照接收端可以选择数据落盘的目标目录，而非始终使用单一目录</li>
<li><strong>same-disk 亲和性</strong>：支持 <code>keepSameDiskWhenLoadingSnapshot</code> 配置（默认 <code>true</code>），尽量保持快照数据与原数据在同一磁盘</li>
</ol>
<pre><code>┌─────────────────────────────────────────────────┐
│      IoTConsensus 多目录快照架构                   │
│                                                  │
│  ┌──────────────────────────────────────┐       │
│  │         DataNode                     │       │
│  │  ┌─────────┐ ┌─────────┐ ┌───────┐  │       │
│  │  │ Disk 1  │ │ Disk 2  │ │Disk N │  │       │
│  │  │ data/   │ │ data/   │ │data/  │  │       │
│  │  │consensus│ │consensus│ │cons.. │  │       │
│  │  └─────────┘ └─────────┘ └───────┘  │       │
│  │       ↑           ↑          ↑       │       │
│  │       └───────────┴──────────┘       │       │
│  │         FolderManager 路由决策        │       │
│  │         - 可用空间感知                │       │
│  │         - same-disk 亲和             │       │
│  └──────────────────────────────────────┘       │
└─────────────────────────────────────────────────┘
</code></pre>
<p>commit <a href="https://github.com/apache/iotdb/pull/17845">#17845</a> 将 <code>keepSameDiskWhenLoadingSnapshot</code> 的默认值设为 <code>true</code>，优先保持数据在同一磁盘——这样在快照恢复时可以避免跨盘复制，加速恢复过程。</p>
<h3>4.3 配套的可靠性增强</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17974">#17974</a> 修复了 IoTConsensus 多目录下 DataRegion 快照加载失败的问题，<a href="https://github.com/apache/iotdb/pull/17935">#17935</a> 确保了 AddPeer 过程中快照加载失败的异常能正确传播，<a href="https://github.com/apache/iotdb/pull/17996">#17996</a> 修复了 <code>MinFolderOccupiedSpaceFirstStrategy</code> 磁盘目录选择策略的空间缓存问题——正是 FolderManager 下沉后多目录路由决策所依赖的策略。</p>
<p>这些修复说明多目录快照虽然是一个基础设施层面的改进，但对正确性的要求极高——快照的一致性问题可能直接导致 Region 不可用。</p>
<hr />
<h2>变更五：系统管理能力增强</h2>
<h3>5.1 手动触发节点负载均衡</h3>
<p>V2.0.10 官宣了手动触发负载均衡的能力（Release Notes: "Add the capability to manually trigger node load balancing"）。有了手动触发，运维可以：</p>
<ul>
<li>在业务低峰期主动触发再均衡</li>
<li>扩容后快速分散新节点的负载</li>
<li>在集群不均衡严重时立即干预</li>
</ul>
<p>值得一提的是，Region 级的手动操作语句（<code>MIGRATE REGION</code> / <code>RECONSTRUCT REGION</code> / <code>EXTEND REGION</code>）在 v2.0.8 的语法中就已存在，本次周期的工作重点在均衡器本身的正确性上：commit <a href="https://github.com/apache/iotdb/pull/17463">#17463</a> 修复了负载均衡服务的一个细节问题，<a href="https://github.com/apache/iotdb/pull/17755">#17755</a> 修复了 Leader 均衡阻塞 Region 激活的问题，<a href="https://github.com/apache/iotdb/pull/17714">#17714</a> 让 PGP 和 Greedy 两种 Region 分配器支持按 database 粒度均衡副本。</p>
<h3>5.2 RemoveDataNode 进度查询</h3>
<p>V2.0.10 为 RemoveDataNode 操作增加了进度查询能力：</p>
<pre><code>┌─────────────────────────────────────────────────┐
│        RemoveDataNode 进度可见性（示意）          │
│                                                  │
│  V2.0.8:                                        │
│    remove datanode → ... → 完成/失败             │
│    (中间过程完全黑盒)                             │
│                                                  │
│  V2.0.10:                                       │
│    remove datanode → 合法性检查                  │
│                    → Region 迁移（可查进度）      │
│                    → 共识组清理                  │
│                    → 完成                        │
└─────────────────────────────────────────────────┘
</code></pre>
<p>commit <a href="https://github.com/apache/iotdb/pull/17878">#17878</a> 还优化了单副本场景下的错误提示，并增加了对 <code>no-available-RegionGroup</code> 竞态的诊断信息；<a href="https://github.com/apache/iotdb/pull/17934">#17934</a> 则确保正在被移除的 DataNode 不会再被分配新 Region。</p>
<h3>5.3 SHOW CONFIGURATION</h3>
<p><code>SHOW CONFIGURATION</code> 语句可以查看集群配置信息。这在多节点集群运维中非常实用——不同节点的配置可能因为历史原因而不一致，<code>SHOW (ALL)? CONFIGURATION (ON nodeId)?</code> 让运维人员可以快速扫描并发现配置差异。</p>
<p>源码考据：这条语法在 v2.0.8 的 <code>RelationalSql.g4</code> 中已逐字存在，2.0.10 属于正式官宣。本周期配套的实际工作包括 <a href="https://github.com/apache/iotdb/pull/17933">#17933</a>（解开配置模板中被注释掉的 set-configuration-able 配置项，修复 <code>enable_topology_probing</code> 等参数的热加载）和 <a href="https://github.com/apache/iotdb/pull/17469">#17469</a>（确保 set configuration 只下发到目标节点——对应 Release Notes 中"配置意外扩散到所有 DataNode"的修复）。</p>
<h3>5.4 ConfigNode Leader 预热优化</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17821">#17821</a> 和 <a href="https://github.com/apache/iotdb/pull/17898">#17898</a> 对 ConfigNode Leader 切换后的预热（warm-up）流程进行了改进，使其在开始服务前完成必要的数据准备，避免刚切换后响应超时。此外 <a href="https://github.com/apache/iotdb/pull/17874">#17874</a> 修复了 AddConfigNode 重试时的幂等性问题。</p>
<h3>5.5 慢写请求统计</h3>
<p>V2.0.10 新增了慢写请求数量统计。这为写入性能诊断提供了数据支撑，与查询侧的慢查询统计形成互补。</p>
<hr />
<h2>变更六：Pipe 持续深耕 — 109 个 commit 的同步引擎打磨</h2>
<p>Pipe 数据同步模块占据了本次发布中<strong>最大比例的 commit 数量</strong>——109 个，约占全部 407 个 commit 的 27%。这体现了社区对数据同步稳定性的高度重视。</p>
<h3>6.1 内存管理优化</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17770">#17770</a> 对 Pipe 内存使用进行了优化，commit <a href="https://github.com/apache/iotdb/pull/17807">#17807</a> 在 scan parser 中计入 page decode 的内存消耗。这些优化联合缓解了大数据量同步场景下的内存压力——Release Notes 中明确提到了"Pipe 子任务内存不足导致同步临时停止"的问题已修复。</p>
<h3>6.2 air-gap Sink 的批处理</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17667">#17667</a> 为 air-gap Sink 实现了批处理逻辑。Air-gap 场景（完全物理隔离的网络环境）中，数据需要先序列化到文件，再通过离线介质传输。批处理优化减少了文件操作次数，显著提升了 air-gap 场景的同步效率。</p>
<h3>6.3 请求切片（Request Slicing）</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17858">#17858</a> 支持通过 sink config key 控制 Pipe 请求切片大小。在跨机房、跨区域同步场景中，过大的单次请求可能导致超时或内存压力，而切片后每次传输的数据量可控。</p>
<h3>6.4 old pipe root user 兼容性</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17985">#17985</a> 修复了老版本 Pipe 中 root 用户兼容性问题，commit <a href="https://github.com/apache/iotdb/pull/17901">#17901</a> 支持了旧版 Pipe 接收端请求的向后兼容。这些兼容性工作对有大量存量 Pipe 实例的环境至关重要。</p>
<h3>6.5 Pipe 稳定性修复一览</h3>
<table>
<thead>
<tr>
<th>修复项</th>
<th>问题描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17991">#17991</a></td>
<td>修复接收端树模型 database 创建问题</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17984">#17984</a></td>
<td>修复 Pipe 文本日期转换错误</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17910">#17910</a></td>
<td>修复 Pipe Schema 快照 database 创建</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17932">#17932</a></td>
<td>修复启动时 hardlink 目录清理阻塞</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17849">#17849</a></td>
<td>修复接收端类型转换加载路径</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17844">#17844</a></td>
<td>修复权限重试和 table parser 进度</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17814">#17814</a></td>
<td>修复 Pipe 密码检查导致账户解锁传播</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17815">#17815</a></td>
<td>修复 Pipe tsfile 接收端 database 处理</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17748">#17748</a></td>
<td>修复 Pipe drop event 因重启感知 committer key 丢失</td>
</tr>
</tbody>
</table>
<hr />
<h2>变更七：隐藏在 commit log 中的重要变更</h2>
<h3>7.1 JDBC PreparedStatement</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17027">#17027</a> 实现了 JDBC 的 PreparedStatement 支持。对于通过 JDBC 接入 IoTDB 的 BI 工具和 ETL 系统，PreparedStatement 不仅防止了 SQL 注入，还支持了批量参数化写入——这是标准 JDBC 使用模式的关键组件。</p>
<h3>7.2 COPY TO TsFile</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17372">#17372</a> 支持了在表模型下使用 <code>COPY TO TsFile</code> 导出查询结果。commit <a href="https://github.com/apache/iotdb/pull/17462">#17462</a>（由本文件作者 Critas 提交）修复了表模型导出时 <code>-q</code> 参数未指定导致的 NPE。</p>
<h3>7.3 查询结果复用 Flushing Memtable</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17718">#17718</a> 修复了一个精巧的 bug：查询复用了正在 flush 的 memtable 中的 TVList，而 flush 过程中 TVList 可能被修改，导致查询读到不一致的数据。修复确保了查询获取 TVList 的快照引用。</p>
<h3>7.4 RPC Dispatch 重复引用已释放的 FragmentInstanceContext</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17794">#17794</a> 修复了一个少见但影响严重的 bug：RPC 重复调度时复用了已释放的 FragmentInstanceContext，导致 NPE。这是分布式查询引擎中典型的"引用生命周期管理"问题。</p>
<h3>7.5 Driver Scheduler 就绪队列预留泄漏</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17919">#17919</a> 修复了 Driver Scheduler 中就绪队列预留槽的泄漏问题。在高并发查询场景中，这个泄漏会逐渐消耗调度器的可用槽位，最终导致查询无法被调度——类似于连接池泄漏但更隐蔽。</p>
<h3>7.6 Netty 升级与 CVE 修复</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17751">#17751</a> 升级了 Netty 版本以修复相关的 CVE 漏洞。这是基础设施层面的安全加固。</p>
<h3>7.7 CLI 密码处理修复</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17914">#17914</a> 修复了 <code>-pw</code> 不带密码参数时可能错误地吞掉后续参数的问题。这是一个典型的命令行参数解析边界 bug。</p>
<h3>7.8 Pipe 日志安全</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17981">#17981</a> 防止了 Pipe Sink 任务 ID 中泄露密钥信息。这是安全编码意识的体现——日志通常被认为是不敏感信息，但其中可能意外包含凭据。</p>
<h3>7.9 FROM-first 查询语法</h3>
<p>commit <a href="https://github.com/apache/iotdb/pull/17410">#17410</a> 悄悄加入了 <strong>FROM-first 查询语法</strong>——允许 <code>FROM t WHERE ... SELECT ...</code> 这种把 FROM 放在最前面的写法（grammar 中新增 <code>fromFirstQuerySpecification</code> 规则）。这与 DuckDB 等现代分析型数据库的趋势一致，符合"先指定数据来源、再描述投影"的思维顺序，也没有出现在 Release Notes 里。</p>
<h3>7.10 客户端修复补充</h3>
<table>
<thead>
<tr>
<th>修复项</th>
<th>问题描述</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/18095">#18095</a></td>
<td>C++ 客户端 DATE 1000-01-01 查询崩溃与 Column 数值类型 getter 缺失</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17571">#17571</a></td>
<td>Session C 异常报告优化</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17464">#17464</a></td>
<td>C++ 客户端 TsBlock 反序列化校验增强</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17400">#17400</a></td>
<td>C++ 客户端非 long 类型时间列访问的 UB 修复</td>
</tr>
<tr>
<td><a href="https://github.com/apache/iotdb/pull/17218">#17218</a></td>
<td>C++ 客户端支持 Visual Studio 2026</td>
</tr>
</tbody>
</table>
<hr />
<h2>问题修复亮点</h2>
<p>V2.0.10 修复了大量影响生产稳定性的关键问题：</p>
<h3>查询相关</h3>
<table>
<thead>
<tr>
<th>问题</th>
<th>影响</th>
</tr>
</thead>
<tbody>
<tr>
<td>kill query 和查询超时在客户端持有连接未完全消费结果集时失效</td>
<td>无法终止失控查询</td>
</tr>
<tr>
<td>树模型多设备超时查询 reservedSize 持续累积，达上限后触发查询错误</td>
<td>长时间运行的查询异常</td>
</tr>
<tr>
<td>树路径全为数字字符时树模型转表模型解析错误</td>
<td>数据迁移失败</td>
</tr>
<tr>
<td>窗口函数状态跨批次重置</td>
<td>聚合结果不正确</td>
</tr>
<tr>
<td>LAST 快速缓存空值处理异常</td>
<td>最新值查询错误</td>
</tr>
</tbody>
</table>
<h3>数据同步</h3>
<table>
<thead>
<tr>
<th>问题</th>
<th>影响</th>
</tr>
</thead>
<tbody>
<tr>
<td>空值插入字段的行无法同步到接收端</td>
<td>数据丢失</td>
</tr>
<tr>
<td>TTL 过期数据幂等逻辑错误导致重复同步</td>
<td>网络带宽浪费，接收端数据膨胀</td>
</tr>
<tr>
<td>enable-send-tsfile-limit 参数无法手动配置</td>
<td>历史 Pipe 速率不可控</td>
</tr>
<tr>
<td>write-back-sink 修改源/目标用户名密码后产生错误日志并阻止数据接收</td>
<td>配置变更后同步中断</td>
</tr>
<tr>
<td>AINode 非 root 用户无法停止进程</td>
<td>权限受限用户运维受阻</td>
</tr>
</tbody>
</table>
<h3>存储与一致性</h3>
<table>
<thead>
<tr>
<th>问题</th>
<th>影响</th>
</tr>
</thead>
<tbody>
<tr>
<td>单节点 ConfigNode Leader 切换导致分区表丢失</td>
<td>数据不可访问</td>
</tr>
<tr>
<td>set configuration 到单个 DataNode 后意外扩散到所有节点</td>
<td>配置管理混乱</td>
</tr>
<tr>
<td>attribute 字段 null 值导致接收端数组越界，阻塞同步管道</td>
<td>同步完全停止</td>
</tr>
<tr>
<td>Load 操作异常重复广播删除标记</td>
<td>数据被错误删除</td>
</tr>
</tbody>
</table>
<hr />
<h2>生产环境升级建议</h2>
<h3>升级前检查清单</h3>
<p>IoTDB 升级操作本身比较简单，替换 <code>lib</code>、<code>sbin</code>、<code>conf</code> 目录后重启即可：</p>
<pre><code># 1. 检查当前版本
./sbin/start-cli.sh -e "show version"

# 2. 备份
cp -r data/ data.backup.$(date +%Y%m%d)
cp -r conf/ conf.backup.$(date +%Y%m%d)

# 3. 替换新版本
cp -r apache-iotdb-2.0.10-all-bin/lib/* $IOTDB_HOME/lib/
cp -r apache-iotdb-2.0.10-all-bin/sbin/* $IOTDB_HOME/sbin/
# conf 需要对比合并，保留原有自定义配置

# 4. 如果使用了 Pipe 同步，升级后做个简单验证
./sbin/start-cli.sh -e "show pipes"

# 5. 如果使用了 C/C++ 客户端，建议同步升级客户端版本
</code></pre>
<h3>按场景的升级建议</h3>
<table>
<thead>
<tr>
<th>使用场景</th>
<th>升级紧迫度</th>
<th>注意事项</th>
</tr>
</thead>
<tbody>
<tr>
<td>使用 CTE/集合操作</td>
<td><strong>强烈推荐</strong></td>
<td>新功能，需确认 SQL 语法兼容性</td>
</tr>
<tr>
<td>嵌入式/边缘场景</td>
<td><strong>强烈推荐</strong></td>
<td>C 语言驱动 SDK 是关键能力</td>
</tr>
<tr>
<td>使用 C/C++ 客户端</td>
<td><strong>建议尽快</strong></td>
<td>多个关键 Bug 修复</td>
</tr>
<tr>
<td>AI 推理</td>
<td>推荐升级</td>
<td>Toto/Moirai2 多模型支持 + 进程隔离</td>
</tr>
<tr>
<td>Pipe 数据同步</td>
<td><strong>建议尽快</strong></td>
<td>大量稳定性修复</td>
</tr>
<tr>
<td>多磁盘部署</td>
<td>推荐升级</td>
<td>IoTConsensus 多目录快照</td>
</tr>
<tr>
<td>kill query / 查询超时</td>
<td><strong>必须升级</strong></td>
<td>关键 Bug 修复</td>
</tr>
<tr>
<td>稳定运行</td>
<td>择机升级</td>
<td>常规版本跟进</td>
</tr>
</tbody>
</table>
<h3>特别提示：跳版本升级</h3>
<p>V2.0.8 到 V2.0.10 跳过了 V2.0.9，升级操作与常规版本一致（见上文检查清单）。但如果你使用了 Pipe 数据同步功能，建议升级后在接收端做一次同步验证，确保跨版本的 Pipe 协议兼容性——本周期恰好有多个新老版本 Pipe 兼容性修复（#17985、#17901）。</p>
<hr />
<h2>总结</h2>
<h3>V2.0.10 反映了什么趋势？</h3>
<ol>
<li>
<p><strong>SQL 化加速</strong> — 从 V2.0.7 的表模型基础 SQL，到 CTE、集合操作、IF 函数、APPROX_PERCENTILE，IoTDB 的表模型正在快速对齐标准 SQL 分析能力。值得玩味的是，这批能力大多在 2.0.8 的代码里就已就位，2.0.10 是稳定化后的集中官宣——"先合入雪藏、稳定后解禁"正在成为社区发布新 SQL 能力的固定节奏。这是时序数据库从"存数据"走向"分析数据"的必经之路。</p>
</li>
<li>
<p><strong>嵌入式生态布局</strong> — C 语言驱动 SDK 的推出，意味着 IoTDB 开始将触角伸向嵌入式设备和边缘计算场景。Java/Go/Python 客户端覆盖云端和服务端，C 驱动覆盖设备端——生态版图正在完整。</p>
</li>
<li>
<p><strong>AI 模型矩阵化</strong> — 从 V2.0.8 的 Chronos-2，到 V2.0.10 的 Toto + Moirai2（外加未官宣的 MOMENT），IoTDB 在构建一个内置的时序模型矩阵。HubMixin 支持和多模型管理架构让这个矩阵可以持续扩展。</p>
</li>
<li>
<p><strong>基础设施深水区</strong> — IoTConsensus 多目录快照、ConfigNode 预热优化、Driver Scheduler 泄漏修复——这些改动不产生直接的用户可见功能，但在大规模集群中决定了系统的稳定边界。</p>
</li>
<li>
<p><strong>Pipe 成熟化仍在进行</strong> — 109 个 Pipe commit 说明数据同步模块依然在快速迭代。Release Notes 列出的 17 个 Bug 修复中有 6 个与 Pipe/同步直接相关，可以看出 Pipe 在边界场景和异常路径上仍有大量工作要做。</p>
</li>
<li>
<p><strong>可观测性持续投入</strong> — SHOW QUERIES 增强、慢写统计、SHOW CONFIGURATION、存储空间统计——每一项都让运维人员手上多一个工具。</p>
</li>
</ol>
<h3>与历史版本的对比</h3>
<table>
<thead>
<tr>
<th>维度</th>
<th>V2.0.8</th>
<th>V2.0.10</th>
</tr>
</thead>
<tbody>
<tr>
<td>主题</td>
<td>AI 增强 + Pipe 架构升级</td>
<td>SQL 能力跃进 + C 生态启航</td>
</tr>
<tr>
<td>commit 数量</td>
<td>638</td>
<td>407（跳版本合并）</td>
</tr>
<tr>
<td>新增模型</td>
<td>Chronos-2</td>
<td>Toto、Moirai2（另有未官宣的 MOMENT）</td>
</tr>
<tr>
<td>SQL 增强</td>
<td>TIME 列自定义命名</td>
<td>CTE、集合操作、IF、APPROX_PERCENTILE、DEBUG SQL、FROM-first</td>
</tr>
<tr>
<td>客户端生态</td>
<td>多语言客户端</td>
<td><strong>C 语言驱动 SDK</strong>、JDBC PreparedStatement</td>
</tr>
<tr>
<td>Pipe 变更</td>
<td>Pipe 分拆、rate limiter</td>
<td>109 commits，air-gap batch、request slicing、内存优化</td>
</tr>
<tr>
<td>存储架构</td>
<td>—</td>
<td>IoTConsensus 多目录快照</td>
</tr>
<tr>
<td>升级风险</td>
<td>低</td>
<td>低（常规 lib/sbin/conf 替换）</td>
</tr>
</tbody>
</table>
<hr />
<h2>参考资料</h2>
<ul>
<li><a href="https://dlcdn.apache.org/iotdb/2.0.10/RELEASE_NOTES.md">IoTDB V2.0.10 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/compare/v2.0.8...v2.0.10">V2.0.8 → V2.0.10 完整 Changelog</a>（407 commits）</li>
<li><a href="https://github.com/apache/iotdb/pull/17347">Session C Interface PR #17347</a></li>
<li><a href="https://github.com/apache/iotdb/pull/17322">Toto Model Integration PR #17322</a></li>
<li><a href="https://github.com/apache/iotdb/pull/17056">Moirai2 Model Integration PR #17056</a></li>
<li><a href="https://github.com/apache/iotdb/pull/16811">IoTConsensus Multi-Dir Snapshot PR #16811</a></li>
<li><a href="https://github.com/apache/iotdb/pull/17027">JDBC PreparedStatement PR #17027</a></li>
<li><a href="https://iotdb.apache.org/Download/">IoTDB 官网下载页</a></li>
<li><a href="https://github.com/apache/iotdb">IoTDB 项目 GitHub</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[版本更新预告：Apache IoTDB 将最低 JDK 提升至 17，并完成 javax → jakarta 迁移]]></title>
            <link>https://critas.wang/posts/iotdb-jdk17-jakarta-migration-preview/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-jdk17-jakarta-migration-preview/</guid>
            <pubDate>Mon, 15 Jun 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB 一次合并到 master 的基线变更：最低 Java 版本提升到 JDK 17，REST/OpenAPI 运行时从 javax.* 迁移到 jakarta.*。本文从依赖现代化、命名空间断裂、升级影响三个角度解读这次变更的来龙去脉。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>这不是一篇已发布版本的解析，而是一篇<strong>预告</strong>。</p>
<p><a href="https://github.com/apache/iotdb/pull/17859">apache/iotdb#17859</a> 已经合并到 master 分支，标题是 <strong>"Upgrade minimum JDK to 17 and migrate JavaX to Jakarta"</strong>。它不会带来任何用户可见的新功能，但它动了一个比新功能更"伤筋动骨"的东西——<strong>项目的运行时基线</strong>：</p>
<ul>
<li>最低 Java 版本从 JDK 8 / 11 的混合基线，统一提升到 <strong>JDK 17</strong>；</li>
<li>REST 服务、OpenAPI 生成代码以及 Jakarta EE 运行时 API，从 <code>javax.*</code> 全面迁移到 <code>jakarta.*</code>；</li>
<li>一大批锁定依赖随之升级：Jetty 12 EE10、Jersey 3、Logback 1.5、ANTLR 4.13、OpenAPI Generator 7、Swagger / Jackson 的 Jakarta 变体。</li>
</ul>
<p>这类变更有一个共同特征：<strong>平时没人会主动碰它，但越拖越贵</strong>。本文不讲"新特性怎么用"，而是讲清楚三件事：</p>
<ol>
<li>为什么是 JDK 17，而不是继续躺在 JDK 8 上？</li>
<li><code>javax → jakarta</code> 这一行 import 的改名，为什么会牵动两百多个文件？</li>
<li>对于已经在生产环境跑着 IoTDB 的人，这次基线变更意味着什么？</li>
</ol>
<blockquote>
<p>本文基于已合并的 <a href="https://github.com/apache/iotdb/pull/17859">PR #17859</a>。由于该变更刚进入 master、尚未随某个正式版本发布，文中的目标版本号（如 TsFile <code>2.3.2</code>）以 PR 中的快照为准，正式发布时可能微调。</p>
</blockquote>
<hr />
<h2>一、为什么是 JDK 17：一次"还技术债"的动作</h2>
<p>IoTDB 长期把 JDK 8 作为最低支持版本——这在 Java 大数据生态里并不少见，Hadoop、早期 Flink 都背着同样的历史包袱。但到 2026 年，继续停留在 JDK 8 / 11 的代价已经越来越难忽视。</p>
<h3>1.1 生命周期：旧版本正在变成"付费才有补丁"</h3>
<p>先看一张 LTS 版本的支持时间线（以 Oracle 口径为主，下游厂商如 Amazon Corretto、Azul、Adoptium 各有差异）：</p>
<table>
<thead>
<tr>
<th>版本</th>
<th>免费公共更新窗口</th>
<th>Oracle 商业支持周期</th>
<th>现状</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>JDK 8</strong></td>
<td>OpenJDK 8 社区更新逐步收尾</td>
<td>商业 EOL 拖到 2030+</td>
<td>免费补丁基本断供，靠付费续命</td>
</tr>
<tr>
<td><strong>JDK 11</strong></td>
<td>免费社区更新约 2024-09 终止</td>
<td>Premier 2023-09 结束，扩展支持到 2032</td>
<td>免费窗口已关，续命需订阅</td>
</tr>
<tr>
<td><strong>JDK 17</strong></td>
<td>生产免费窗口至 2024-09</td>
<td>Premier 约 2026-09，总计到 2029</td>
<td>仍在主流维护期内</td>
</tr>
</tbody>
</table>
<blockquote>
<p>表中"免费公共更新窗口"指 Oracle JDK 免费用于生产的截止点，"商业支持周期"指付费订阅可获得补丁的区间——两者是不同维度，前者先关、后者后结束。下游厂商（Amazon Corretto、Azul、Adoptium 等）各自的免费窗口通常更长，需按实际发行版确认。</p>
</blockquote>
<p>这张表想说的不是"JDK 17 永远安全"，而是一个更现实的判断：<strong>JDK 8 / 11 早已越过免费安全补丁的分水岭</strong>。继续把它们作为<em>最低</em>基线，意味着官方要为一批拿不到上游安全更新的运行时持续做兼容性维护——这对一个时序数据库项目来说是纯粹的负担。</p>
<p>把最低门槛抬到 JDK 17，本质是把"还能拿到主流安全更新"作为底线：<strong>让项目运行在一个仍在被积极打补丁的 JVM 上</strong>，而不是停留在一个连上游都不再免费修复的版本里。安全收益的关键不在某几个具体漏洞编号，而在补丁通道是否还畅通——JDK 8 / 11 的免费补丁通道已经关闭，JDK 17 还开着。</p>
<h3>1.2 真正的连锁反应：依赖生态在抛弃旧 JDK</h3>
<p>比 JVM 自身 EOL 更有压迫感的，是<strong>第三方库正在集体上调最低 JDK 要求</strong>。这正是 PR #17859 里那一长串依赖升级的根本驱动：</p>
<ul>
<li><strong>Jetty 12 / EE10</strong> 要求 JDK 17+；</li>
<li><strong>Jersey 3.x</strong>（JAX-RS 实现）跟随 Jakarta EE 9+，告别 <code>javax</code>；</li>
<li><strong>Logback 1.5</strong>、<strong>Jackson</strong> 的 Jakarta RS provider、<strong>Swagger</strong> 的 Jakarta 变体，全部围绕 <code>jakarta.*</code> 命名空间重建。</li>
</ul>
<p>换句话说，IoTDB 即便不主动升 JDK，它依赖的 Web/REST 技术栈也已经<strong>没有还停留在 JDK 8 + javax 的新版本可用了</strong>。继续锁在老版本，等于放弃这些库后续的安全修复和 bug 修复。</p>
<p>所以这次变更的逻辑链条是：</p>
<pre><code>依赖库停止支持 JDK 8 / javax
        ↓
想升级依赖 → 必须升 JDK + 换命名空间
        ↓
最低基线提到 JDK 17 + 全量迁移 jakarta
</code></pre>
<p>JDK 17 在这里不是"追新"，而是<strong>被生态推着走</strong>的最低代价选择。</p>
<hr />
<h2>二、javax → jakarta：一行改名，两百个文件</h2>
<p>很多人第一次听说 <code>javax → jakarta</code> 会有个直觉：不就是 import 改个前缀吗，IDE 全局替换一下不就完了？</p>
<p>要理解为什么 PR #17859 会触及两百多个文件，得先搞清楚这次改名的<strong>性质</strong>。</p>
<h3>2.1 这是一次"商标驱动"的断裂，不是技术升级</h3>
<p>2019 年，Oracle 把 Java EE 捐给了 Eclipse 基金会，但<strong>保留了 <code>javax</code> 这个命名空间的商标权</strong>。于是从 Jakarta EE 9 开始，所有企业级 EE API 的包名被迫从 <code>javax.*</code> 改成 <code>jakarta.*</code>：</p>
<pre><code>// 旧（Java EE / javax）
import javax.ws.rs.GET;
import javax.validation.constraints.NotNull;
import javax.annotation.Generated;

// 新（Jakarta EE 9+ / jakarta）
import jakarta.ws.rs.GET;
import jakarta.validation.constraints.NotNull;
import jakarta.annotation.Generated;
</code></pre>
<p>关键在于，<strong>这是一次不向后兼容的硬断裂</strong>：</p>
<ul>
<li>Jakarta EE 9 之后的服务器（Tomcat 10、Jetty 12 等）<strong>只认 <code>jakarta.*</code></strong>，不再识别 <code>javax.*</code>；</li>
<li>同一个类，<code>javax</code> 版和 <code>jakarta</code> 版在 classpath 上是<strong>两个完全不同的类</strong>，混用会直接抛 <code>ClassNotFoundException</code> / <code>NoClassDefFoundError</code>；</li>
<li>规范本身<strong>不保证任何向后兼容</strong>，要不要兼容由各实现自己决定——而主流实现选择了"不兼容"。</li>
</ul>
<p>这就是为什么"全局替换前缀"看起来简单，实际却是一次需要逐模块验证的迁移。</p>
<h3>2.2 IoTDB 这次迁移触及了哪些角落</h3>
<p>从 PR 的改动范围看，迁移并不局限于 REST 接口，而是渗透到了几个层次：</p>
<table>
<thead>
<tr>
<th>层次</th>
<th>涉及内容</th>
<th>javax → jakarta 的体现</th>
</tr>
</thead>
<tbody>
<tr>
<td>REST / JAX-RS</td>
<td><code>external-service-impl/rest</code>、<code>rest-openapi</code></td>
<td><code>javax.ws.rs.*</code> → <code>jakarta.ws.rs.*</code></td>
</tr>
<tr>
<td>校验注解</td>
<td><code>iotdb-core</code>（datanode / confignode / consensus）</td>
<td><code>javax.validation</code> → <code>jakarta.validation</code></td>
</tr>
<tr>
<td>OpenAPI 生成代码</td>
<td>OpenAPI Generator 7 重新生成</td>
<td>生成模板切换到 jakarta</td>
</tr>
<tr>
<td>Thrift 协议模块</td>
<td>多个 <code>thrift-*</code> 模块</td>
<td>见下方"踩坑点"</td>
</tr>
</tbody>
</table>
<h3>2.3 一个值得记下来的踩坑点：Thrift 的 <code>@Generated</code></h3>
<p>迁移里有个细节很能说明"硬断裂"的麻烦之处。</p>
<p>代码生成器（Thrift）会在生成的类上打 <code>@Generated</code> 注解。这个注解在 jakarta 体系下应该是 <code>jakarta.annotation.Generated</code>，但 <strong>Thrift 0.14.1 还不认识这个 jakarta 版本的注解</strong>。结果就是：迁移到 jakarta 后，Thrift 生成的代码反而带上了一个它自己不支持的注解。</p>
<p>PR 的处理方式是<strong>抑制掉 Thrift 生成代码里的 <code>@Generated</code> 注解</strong>——绕开这个工具链尚未跟上的缺口。</p>
<p>这类"A 升级了但 B 还没跟上"的缝隙，正是 javax → jakarta 迁移在真实大型项目里最耗时的部分：<strong>改 import 是机械劳动，处理工具链断层才是真功夫</strong>。</p>
<blockquote>
<p><strong>进展跟进：工具链正在补上这个缺口</strong></p>
<p>"抑制注解"只是临时绕行，真正的根治是把 Thrift 编译器本身升上去。就在 #17859 合并前后，IoTDB 的 Thrift 工具链也在同步推进——<a href="https://github.com/apache/iotdb-bin-resources/pull/68">apache/iotdb-bin-resources#68</a>（已合并）发布了基于 <strong>Apache Thrift 0.23.0</strong> 的编译器产物 <code>iotdb-tools-thrift 0.23.0.0</code>，并配套了多平台 CI 构建流程。</p>
<p>也就是说，IoTDB 用的 Thrift 工具链正从 0.14.x 一代向 0.23.0 演进。等新工具链全面落地，前面那个"只能抑制 <code>@Generated</code>"的临时手段，未来有望被更彻底的方案取代。这条线是独立仓库、独立进度，属于这次基线升级的<strong>配套工程</strong>——值得放在一起看，但不必和主 PR 绑死。</p>
</blockquote>
<p>另外两个值得注意的边界（PR 中明确保留，没有动）：</p>
<ul>
<li><strong>JSR-305 注解</strong>（<code>javax.annotation.Nonnull</code> / <code>Nullable</code>）<strong>保留不动</strong>——它们是纯静态分析注解，不属于 EE 运行时，也不阻碍迁移；</li>
<li>REST 示例和集成测试里的 <strong>Apache HttpClient 保持原样</strong>——它本就不在 javax/jakarta 命名空间之列。</li>
</ul>
<p>能分清"哪些必须改、哪些不该碰"，是这类迁移做得干净的标志。</p>
<hr />
<h2>三、对生产环境意味着什么</h2>
<p>如果你正在生产环境跑 IoTDB，这次基线变更落到正式版本后，有几件事需要提前规划。</p>
<h3>3.1 升级前的检查清单</h3>
<pre><code>□ 运行时 JVM 是否已是 JDK 17+？
   └─ 这是硬门槛。新版本将不再支持 JDK 8 / 11 启动。

□ 启动脚本是否依赖特定 JAVA_VERSION 行为？
   └─ PR 中已修复 Windows 启动脚本对空 JAVA_VERSION 的处理，
      自定义过启动脚本的环境需对照检查。

□ 是否有外挂的、依赖 IoTDB REST 接口的集成？
   └─ REST 服务底层从 Jersey 2/javax 换到 Jersey 3/jakarta，
      对外 HTTP 契约不变，但若你打包进了同一 JVM 进程、
      或基于内部类做过扩展，需要重新验证。

□ 自定义插件 / UDF 是否引用了 javax.* 的 EE 注解？
   └─ 若有，需同步迁移到 jakarta.*。
</code></pre>
<h3>3.2 谁会"无感"，谁要"留神"</h3>
<ul>
<li><strong>纯客户端用户</strong>（通过 JDBC / Session / 各语言客户端连接）：基本无感。命名空间迁移发生在服务端内部，对外协议不变。你只需确保<strong>部署 IoTDB 的那台机器</strong>装了 JDK 17+。</li>
<li><strong>运维 / 部署方</strong>：核心动作就一个——<strong>把运行 IoTDB 的 JVM 升到 17+</strong>。这是这次变更对绝大多数人唯一的实质影响。</li>
<li><strong>二次开发 / 插件作者</strong>：需要 review 自己的代码里是否用到了 <code>javax.*</code> 的 EE 注解（校验、JAX-RS 等），并跟随迁移。</li>
</ul>
<h3>3.3 一句话建议</h3>
<blockquote>
<p>对运维而言，这次变更的本质是：<strong>"换 JVM" 比 "换版本" 更重要</strong>。
先把目标环境的 JDK 准备到 17+，正式版本发布后的升级才会顺滑。</p>
</blockquote>
<hr />
<h2>四、小结</h2>
<p>PR #17859 是一次典型的"基线还债"——没有炫目的新功能，却把项目从一个逐渐失去安全更新和生态支持的旧基线上，拉到了一个仍被主流积极维护的位置。</p>
<p>三个要点回顾：</p>
<ol>
<li><strong>JDK 17 是被生态推着走的最低代价</strong>：核心收益是"补丁通道还畅通"——JDK 8 / 11 的免费安全更新已断供，且依赖库也不再为 JDK 8 / javax 出新版本。</li>
<li><strong>javax → jakarta 是商标驱动的硬断裂</strong>：不向后兼容，触及 REST、校验注解、OpenAPI、Thrift 多个层次，最耗时的不是改 import，而是处理 Thrift 这类工具链断层。</li>
<li><strong>对生产环境，核心动作只有一个</strong>：把运行 IoTDB 的 JVM 升到 JDK 17+，其余大多无感。</li>
</ol>
<p>等这次变更正式随版本发布，我会再写一篇结合实际升级体验的跟进。</p>
<hr />
<blockquote>
<p><strong>延伸阅读</strong></p>
<ul>
<li><a href="https://github.com/apache/iotdb/pull/17859">Apache IoTDB PR #17859 — Upgrade minimum JDK to 17 and migrate JavaX to Jakarta</a></li>
<li><a href="https://github.com/apache/iotdb-bin-resources/pull/68">Apache IoTDB bin-resources PR #68 — Release thrift 0.23.0 tool</a></li>
<li><a href="https://jakarta.ee/blogs/javax-jakartaee-namespace-ecosystem-progress/">Javax to Jakarta Namespace Ecosystem Progress — Eclipse Foundation</a></li>
<li><a href="https://www.oracle.com/java/technologies/java-se-support-roadmap.html">Oracle Java SE Support Roadmap</a></li>
<li><a href="https://medium.com/@hsjoshi28/java-ee-to-jakarta-ee-with-jdk-17-and-spring-boot-step-by-step-guide-e73744d3e2f4">Migrate from Java EE to Jakarta EE with JDK 17 — step-by-step</a></li>
</ul>
</blockquote>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB C# 客户端双版本发布：V1.3.7 与 V2.0.8 解析及版本选择指南]]></title>
            <link>https://critas.wang/posts/iotdb-client-csharp-v137-v208/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-client-csharp-v137-v208/</guid>
            <pubDate>Wed, 15 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB C# 客户端 V1.3.7 与 V2.0.8 同步发布，本文梳理两个版本的核心变更、兼容性边界以及在 1.x 与 2.x 数据库下的选型建议。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>2026 年 4 月 15 日，Apache IoTDB C# 客户端（<code>iotdb-client-csharp</code>）同时发布了两个版本：</p>
<ul>
<li><a href="https://github.com/apache/iotdb-client-csharp/releases/tag/v1.3.7"><strong>v1.3.7</strong></a> — 1.x 分支的维护版本，<strong>同时可用于 2.x 数据库</strong>（仅限 Tree Model）</li>
<li><a href="https://github.com/apache/iotdb-client-csharp/releases/tag/v2.0.8"><strong>v2.0.8</strong></a> — 面向 IoTDB <strong>2.x</strong> 服务端的新一代客户端，<strong>不兼容 1.x 数据库</strong></li>
</ul>
<blockquote>
<p><strong>⚠️ 重要兼容性提示</strong></p>
<p>两个版本的兼容方向是<strong>不对称</strong>的：</p>
<ul>
<li><strong>v2.0.8 无法连接 1.x 数据库</strong>。如果服务端仍在 IoTDB 1.x（例如 V1.3.6 / V1.3.7），必须使用 <strong>v1.3.7</strong> 客户端。</li>
<li><strong>v1.3.7 可以连接 2.x 数据库</strong>，但<strong>只能使用 Tree Model</strong>，无法使用 2.x 新增的 Table Model。需要 Table Model 时才升级到 v2.0.8。</li>
</ul>
<p>换句话说：<strong>v1.3.7 是兼容范围更广的"保守选择"，v2.0.8 是面向 2.x 新特性的"激进选择"</strong>。</p>
</blockquote>
<p>本文梳理以下内容：</p>
<ol>
<li>V1.3.7 的核心修复</li>
<li>V2.0.8 的新特性与改进</li>
<li>1.x ↔ 2.x 兼容性边界</li>
<li>选型与升级建议</li>
</ol>
<hr />
<h2>V1.3.7：稳定性修复，兼顾 1.x 与 2.x（Tree Model）</h2>
<p>V1.3.7 是 1.x 分支的一次"小步快跑"维护版本，主要聚焦于会话管理和数据读取链路上的若干历史缺陷。</p>
<p><strong>它的连接范围其实是两个大版本</strong>：</p>
<ul>
<li>对 IoTDB <strong>1.x</strong> 服务端 — 原生支持，推荐升级</li>
<li>对 IoTDB <strong>2.x</strong> 服务端 — <strong>可用，但只能访问 Tree Model</strong>，无法使用 2.x 新增的 Table Model</li>
</ul>
<p>对于生产环境中仍在使用 1.3.x 服务端、或者已升级到 2.x 但只需要 Tree Model 的用户，这是一次<strong>推荐升级</strong>。</p>
<h3>核心变更</h3>
<table>
<thead>
<tr>
<th>变更项</th>
<th>说明</th>
<th>影响</th>
</tr>
</thead>
<tbody>
<tr>
<td>SessionPool 客户端泄漏修复</td>
<td>修复重连失败、查询失败时连接未正确归还的资源泄漏</td>
<td>长时间运行的服务不再出现句柄/连接耗尽</td>
</tr>
<tr>
<td>服务端错误信息保留</td>
<td>将服务端返回的错误消息原样透传给调用方</td>
<td>调试更直接，不再被包装层吞掉</td>
</tr>
<tr>
<td>SessionDataSet 死锁修复</td>
<td>修复数据集操作中的同步死锁</td>
<td>高并发查询场景稳定性提升</td>
</tr>
<tr>
<td>RowRecord 构造函数升级</td>
<td>迁移到 4 参数 <code>RowRecord</code> 构造函数</td>
<td>更完整的数据结构表达</td>
</tr>
</tbody>
</table>
<h3>适用场景</h3>
<ul>
<li>服务端是 IoTDB 1.3.x（含 1.3.6 / 1.3.7）</li>
<li>服务端已是 2.x，但业务只使用 Tree Model、不需要 Table Model</li>
<li>使用 SessionPool 且长时间运行</li>
<li>需要在业务侧捕获服务端原始错误信息</li>
<li>对数据读取链路的死锁问题敏感</li>
</ul>
<p><strong>完整 Changelog</strong>：<a href="https://github.com/apache/iotdb-client-csharp/compare/v1.3.4...v1.3.7">v1.3.4...v1.3.7</a></p>
<hr />
<h2>V2.0.8：面向 2.x 的新特性与协议适配</h2>
<p>V2.0.8 是 2.x 分支的一次较大更新，既包含 V1.3.7 的全部稳定性修复，又引入了针对 IoTDB 2.x 服务端的新协议支持和安全能力。</p>
<h3>新特性（New Features）</h3>
<h4>1. 支持 V2 读接口（<code>C# Client support V2 read interface</code>）</h4>
<p>这是 V2.0.8 <strong>最关键的变更</strong>。IoTDB 2.x 服务端在读取路径上引入了 V2 接口（更高效的数据编码、改进的列式传输），V2.0.8 客户端原生支持该接口。</p>
<blockquote>
<p><strong>这也是为什么 V2.0.8 无法连接 1.x 服务端</strong> — 1.x 服务端不存在 V2 读接口的实现，协议握手阶段就会失败。</p>
</blockquote>
<h4>2. 支持 Client TLS</h4>
<p>新增客户端侧 TLS 加密能力：</p>
<ul>
<li>面向跨网络/跨云边界的部署场景</li>
<li>配合服务端 2.x 的 TLS 配置，可实现端到端的传输加密</li>
<li>对金融、能源、政企等合规要求高的行业尤为重要</li>
</ul>
<h3>改进（Improvements）</h3>
<table>
<thead>
<tr>
<th>改进项</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>NuGet 包元数据增强</td>
<td>改进在 NuGet 上的可发现性与描述信息</td>
</tr>
<tr>
<td><code>Array.Reverse</code> 替换 LINQ 反转</td>
<td>跨 .NET 运行时（.NET Framework / .NET 6+ / .NET 8+）兼容性更好，性能略优</td>
</tr>
</tbody>
</table>
<h3>Bug 修复（继承自 V1.3.7 并新增）</h3>
<ul>
<li>SessionPool 客户端资源泄漏修复</li>
<li>服务端错误信息保留</li>
<li><code>RpcDataSet</code> 死锁条件修复</li>
<li><strong>时区兼容性问题修复</strong>（2.x 独有）</li>
<li><strong>列索引问题修复</strong>（2.x 独有）</li>
<li>移除废弃代码</li>
</ul>
<h3>贡献者</h3>
<p>本次 V2.0.8 由 4 位开发者贡献，包括首次参与的 <code>thompson-tomo</code>。从 v2.0.2 到 v2.0.8，共合并了 6 个主要 PR。</p>
<p><strong>完整 Changelog</strong>：<a href="https://github.com/apache/iotdb-client-csharp/compare/v2.0.2...v2.0.8">v2.0.2...v2.0.8</a></p>
<hr />
<h2>1.x 与 2.x 的兼容性边界</h2>
<p>这是本次发布中<strong>最容易踩坑</strong>的一点，单独拎出来讲清楚。兼容方向并不对称。</p>
<h3>兼容性矩阵</h3>
<table>
<thead>
<tr>
<th>客户端版本</th>
<th>服务端 1.x (1.3.x)</th>
<th>服务端 2.x (Tree Model)</th>
<th>服务端 2.x (Table Model)</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>C# Client v1.3.7</strong></td>
<td>✅ 支持</td>
<td>✅ 支持</td>
<td>❌ 不支持</td>
</tr>
<tr>
<td><strong>C# Client v2.0.8</strong></td>
<td>❌ <strong>不支持</strong></td>
<td>✅ 支持</td>
<td>✅ 支持</td>
</tr>
</tbody>
</table>
<p>一句话概括：</p>
<ul>
<li><strong>v1.3.7 是"向上兼容"的</strong>：能连 1.x，也能连 2.x（只是用不了 Table Model）</li>
<li><strong>v2.0.8 是"只向前不向后"的</strong>：只能连 2.x，但能用 Table Model</li>
</ul>
<h3>为什么 v2.0.8 连不上 1.x？</h3>
<p>IoTDB 从 1.x 到 2.x 的演进不仅是版本号的递进，还带来了：</p>
<ol>
<li><strong>RPC 协议层的重构</strong> — 2.x 引入了 V2 读接口，是一套新的 Thrift 定义</li>
<li><strong>数据模型的扩展</strong> — 2.x 新增 Table Model（表模型），与 Tree Model 并存</li>
<li><strong>会话与元数据交互路径变化</strong> — 例如 Database 概念替代了 Storage Group</li>
</ol>
<p>V2.0.8 客户端默认走 V2 读接口和新的会话路径，而 1.x 服务端不存在这些实现，握手阶段就会失败：</p>
<pre><code>连接阶段：握手报错 / 协议版本不匹配
查询阶段：响应解析异常 / 字段错位
写入阶段：schema 校验失败
</code></pre>
<h3>为什么 v1.3.7 还能连 2.x？</h3>
<p>2.x 服务端<strong>保留了对旧版 RPC 接口和 Tree Model 的向后兼容</strong>，因此 v1.3.7 客户端发出的 1.x 风格请求仍能被正确处理。代价是：</p>
<ul>
<li><strong>Table Model 相关的 API、DDL、查询在 v1.3.7 里不存在</strong> — 客户端根本不会调用这些接口</li>
<li>无法享受 V2 读接口带来的性能优化</li>
<li>缺少 v2.0.8 独有的 Client TLS 能力</li>
</ul>
<h3>如何确认服务端版本</h3>
<p>在 CLI 或通过 SQL 查询：</p>
<pre><code>SHOW VERSION;
</code></pre>
<p>根据返回结果选择对应的 C# 客户端版本。</p>
<hr />
<h2>选型与升级建议</h2>
<h3>场景一：服务端在 1.3.x，短期不升级</h3>
<p><strong>建议</strong>：使用 <code>Apache.IoTDB</code> 的 v1.3.7。</p>
<pre><code>
&lt;PackageReference Include="Apache.IoTDB" Version="1.3.7" /&gt;
</code></pre>
<p>收益：修复了 SessionPool 泄漏与 <code>SessionDataSet</code> 死锁，长时间运行的 .NET 服务会更稳定。</p>
<h3>场景二：服务端已升级到 2.x，但业务只用 Tree Model</h3>
<p><strong>建议</strong>：<strong>依然用 v1.3.7 即可</strong>，不必强行切到 v2.0.8。</p>
<pre><code>&lt;PackageReference Include="Apache.IoTDB" Version="1.3.7" /&gt;
</code></pre>
<p>理由：</p>
<ul>
<li>v1.3.7 能正常连接 2.x 服务端并读写 Tree Model 数据</li>
<li>无需为"升级客户端"付出回归测试成本</li>
<li>只有以下情况才需要升到 v2.0.8：
<ul>
<li>需要使用 <strong>Table Model</strong></li>
<li>需要 <strong>Client TLS</strong> 加密</li>
<li>想要 V2 读接口的<strong>性能提升</strong></li>
</ul>
</li>
</ul>
<h3>场景三：服务端是 2.x，且需要 Table Model / TLS / V2 读接口</h3>
<p><strong>建议</strong>：升级到 v2.0.8。</p>
<pre><code>&lt;PackageReference Include="Apache.IoTDB" Version="2.0.8" /&gt;
</code></pre>
<p>切换时关注：TLS 配置、时区设置、V2 读接口带来的性能与行为变化。参考服务端版本解析：<a href="/posts/iotdb-v207-v137-overview/">IoTDB V2.0.7 与 V1.3.7 解析</a>、<a href="/posts/iotdb-v208-release-notes/">V2.0.8 版本解析</a>。</p>
<h3>场景四：混合集群（部分 1.x、部分 2.x）</h3>
<p><strong>建议</strong>：<strong>统一使用 v1.3.7</strong> 是最简单的做法——一套客户端即可覆盖两种服务端（Tree Model 范围内）。</p>
<p>如果 2.x 集群上必须使用 Table Model，则需按目标集群做隔离：</p>
<ul>
<li>在 DI 容器中按配置切换 <code>ISessionPool</code> 的实现版本</li>
<li>或以微服务方式将 1.x 与 2.x 的访问拆到不同服务中</li>
</ul>
<blockquote>
<p><strong>更省事的替代方案</strong>：如果你的 2.x 集群暂时还不用 Table Model，<strong>直接全量使用 v1.3.7</strong> 就能同时覆盖 1.x 和 2.x 服务端，省去上述的拆分工作。等到真的需要 Table Model 时再考虑迁移到 v2.0.8。</p>
</blockquote>
<h3>通用注意事项</h3>
<ul>
<li><strong>TLS</strong>：v2.0.8 引入 Client TLS，服务端也需启用相应证书，否则握手失败。</li>
<li><strong>时区</strong>：v2.0.8 修复了时区兼容性问题，升级后原本靠客户端"歪打正着"跑通的时区逻辑需要重新核对。</li>
<li><strong>列索引</strong>：如果此前的业务代码依赖特定列索引顺序，v2.0.8 升级后请用单元测试回归一遍。</li>
<li><strong>SessionPool</strong>：两个版本都修复了资源泄漏，但<strong>升级后也要检查业务侧是否有未 <code>Dispose</code> 的路径</strong>，修复只是让正确用法变得更稳健，并不能掩盖错误用法。</li>
</ul>
<hr />
<h2>小结</h2>
<table>
<thead>
<tr>
<th>维度</th>
<th>V1.3.7</th>
<th>V2.0.8</th>
</tr>
</thead>
<tbody>
<tr>
<td>目标服务端</td>
<td>IoTDB 1.x 和 2.x（Tree Model）</td>
<td>IoTDB 2.x（含 Table Model）</td>
</tr>
<tr>
<td>能否连接 1.x 服务端</td>
<td>✅</td>
<td>❌</td>
</tr>
<tr>
<td>能否连接 2.x 服务端</td>
<td>✅（仅 Tree Model）</td>
<td>✅（Tree + Table Model）</td>
</tr>
<tr>
<td>新特性</td>
<td>无</td>
<td>V2 读接口、Client TLS</td>
</tr>
<tr>
<td>稳定性修复</td>
<td>SessionPool / SessionDataSet / 错误透传</td>
<td>同 V1.3.7 + 时区 + 列索引</td>
</tr>
<tr>
<td>推荐升级策略</td>
<td>适用大多数场景的保守选择</td>
<td>需要 Table Model / TLS 时升级</td>
</tr>
</tbody>
</table>
<p><strong>一句话总结</strong>：<strong>v1.3.7 是兼容性最广的选择</strong>，能同时覆盖 1.x 和 2.x 服务端（Tree Model）；<strong>v2.0.8 是面向 2.x 新特性的选择</strong>，需要 Table Model 或 Client TLS 时才升级，但注意它无法连接 1.x 数据库。</p>
<hr />
<h2>参考链接</h2>
<ul>
<li><a href="https://github.com/apache/iotdb-client-csharp/releases/tag/v1.3.7">iotdb-client-csharp v1.3.7 Release</a></li>
<li><a href="https://github.com/apache/iotdb-client-csharp/releases/tag/v2.0.8">iotdb-client-csharp v2.0.8 Release</a></li>
<li><a href="/posts/iotdb-v208-release-notes/">Apache IoTDB V2.0.8 服务端版本解析</a></li>
<li><a href="/posts/iotdb-v207-v137-overview/">Apache IoTDB V2.0.7 与 V1.3.7 服务端概览</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB V2.0.8 版本解析：AI 推理增强与数据管理优化]]></title>
            <link>https://critas.wang/posts/iotdb-v208-release-notes/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-v208-release-notes/</guid>
            <pubDate>Tue, 14 Apr 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB V2.0.8 版本深度分析，包括 Chronos-2 模型集成、并发推理能力、TIME 列自定义命名、Pipe 路径配置增强等架构决策解读。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>Apache IoTDB V2.0.8 于 2026-04-14 发布。如果说 V2.0.7 的主题是"安全加固"，那么 V2.0.8 的主题就是 <strong>AI 能力扩展与数据管理精细化</strong>。</p>
<p>本次更新最引人注目的是 AI 模块的两项增强：内置 Chronos-2 时序大模型，以及为 Timer-XL、Sundial 等内置模型增加并发推理支持。在数据库核心能力上，TIME 列自定义命名和 Pipe 路径配置的灵活化也值得深入分析。</p>
<p>本文从以下几个维度进行解读：</p>
<ol>
<li><strong>Chronos-2 集成</strong> — 为什么选择 Chronos-2？对时序预测意味着什么？</li>
<li><strong>并发推理能力</strong> — 从单线程到并发，架构上做了什么改变？</li>
<li><strong>TIME 列自定义命名</strong> — 看似简单的功能背后的兼容性考量</li>
<li><strong>Pipe 数据同步全面增强</strong> — 路径过滤、速率限制、全量同步拆分</li>
<li><strong>隐藏在 commit log 中的重要变更</strong> — 性能优化、安全加固、数据加载改进</li>
<li><strong>生产环境升级建议</strong></li>
</ol>
<blockquote>
<p>本文内容参考了 <a href="https://mp.weixin.qq.com/s/wW_k9ZlxNGmVyG_rFNuYBA">Apache IoTDB 公众号发布说明</a>、<a href="https://raw.githubusercontent.com/apache/iotdb/releases/tag/v2.0.8">GitHub Release Notes</a> 以及 <a href="https://github.com/apache/iotdb/compare/v2.0.7...v2.0.8">v2.0.7...v2.0.8 的 250 个 commit</a>。</p>
</blockquote>
<hr />
<h2>变更一：内置 Chronos-2 模型 — 时序预测的新选择</h2>
<h3>什么是 Chronos-2？</h3>
<p>Chronos-2 是 Amazon 开源的时序基础模型（Foundation Model），基于 T5 架构，通过将时序数据 tokenize 为离散 token 来进行预训练。它的核心思路是：<strong>把时序预测当作语言建模问题来解决</strong>。</p>
<pre><code>┌──────────────────────────────────────────────┐
│              传统时序模型                      │
│  原始数据 → 特征工程 → 模型训练 → 预测        │
│  (每个数据集都需要单独训练)                    │
├──────────────────────────────────────────────┤
│              Chronos-2                        │
│  原始数据 → Tokenize → 预训练模型 → 预测      │
│  (零样本推理，无需针对特定数据集训练)           │
└──────────────────────────────────────────────┘
</code></pre>
<h3>为什么选择 Chronos-2？</h3>
<p>IoTDB 此前已内置了 Timer-XL 和 Sundial 两个时序模型。引入 Chronos-2 的决策背后，可能有以下考量：</p>
<table>
<thead>
<tr>
<th>维度</th>
<th>Timer-XL / Sundial</th>
<th>Chronos-2</th>
</tr>
</thead>
<tbody>
<tr>
<td>推理方式</td>
<td>需要微调或适配</td>
<td>零样本推理（Zero-shot）</td>
</tr>
<tr>
<td>模型规模</td>
<td>相对轻量</td>
<td>多种规模可选（Mini → Large）</td>
</tr>
<tr>
<td>生态</td>
<td>IoTDB 社区</td>
<td>Amazon 开源，社区活跃</td>
</tr>
<tr>
<td>适用场景</td>
<td>特定领域优化</td>
<td>通用时序预测</td>
</tr>
</tbody>
</table>
<p><strong>对用户的意义：</strong> 如果你的场景是快速验证或跨域预测（例如把工业数据模型迁移到能源场景），Chronos-2 的零样本能力可以大幅降低上手成本。</p>
<h3>使用方式</h3>
<pre><code>-- 使用 Chronos-2 进行时序预测（推测性语法）
SELECT chronos2_forecast(temperature, 'steps=24') 
FROM root.factory.device1
WHERE time &gt;= 2026-04-01 AND time &lt; 2026-04-14;
</code></pre>
<hr />
<h2>变更二：并发推理能力 — 从串行到并行的架构升级</h2>
<h3>变更前的问题</h3>
<p>在 V2.0.7 及之前，内置 AI 模型（Timer-XL、Sundial）的推理是串行执行的：</p>
<pre><code>┌─────────────────────────────────────────┐
│           串行推理 (V2.0.7)              │
│                                         │
│  请求1 ──▶ [推理] ──▶ 返回              │
│                    请求2 ──▶ [推理] ──▶  │
│                              请求3 ──▶  │
│                                         │
│  总耗时 = T1 + T2 + T3                  │
└─────────────────────────────────────────┘
</code></pre>
<p>当多个客户端同时发起 AI 推理请求时，后续请求只能排队等待。在高并发场景下（如多条产线同时做预测性维护），这成为性能瓶颈。</p>
<h3>变更后</h3>
<p>V2.0.8 为内置模型增加了并发推理支持：</p>
<pre><code>┌─────────────────────────────────────────┐
│           并发推理 (V2.0.8)              │
│                                         │
│  请求1 ──▶ [推理线程1] ──▶ 返回         │
│  请求2 ──▶ [推理线程2] ──▶ 返回         │
│  请求3 ──▶ [推理线程3] ──▶ 返回         │
│                                         │
│  总耗时 ≈ max(T1, T2, T3)              │
└─────────────────────────────────────────┘
</code></pre>
<h3>架构思考</h3>
<p>并发推理不是简单地开多线程。需要考虑：</p>
<ol>
<li><strong>模型实例管理</strong> — 是共享一个模型实例加锁，还是维护模型实例池？</li>
<li><strong>内存控制</strong> — 多个推理任务并行时，GPU/CPU 内存如何管控？</li>
<li><strong>请求调度</strong> — 是 FIFO 队列还是优先级调度？</li>
<li><strong>资源隔离</strong> — AI 推理不应影响核心的读写性能</li>
</ol>
<p>这个变更标志着 IoTDB 的 AI 模块从"可用"走向"可用于生产"。</p>
<hr />
<h2>变更三：TIME 列自定义命名</h2>
<h3>变更内容</h3>
<p>在 V2.0.8 之前，时间列的名称固定为 <code>time</code>。现在支持自定义：</p>
<pre><code>-- V2.0.7：时间列名称固定
SELECT time, temperature FROM root.sg.d1;
-- 结果列: time | temperature

-- V2.0.8：支持自定义时间列名
-- 具体语法取决于表模型的 DDL 定义
</code></pre>
<h3>为什么需要这个功能？</h3>
<p>看似微小的变更，实际上解决了几个实际痛点：</p>
<p><strong>1. 与外部系统集成时的列名冲突</strong></p>
<p>很多 ETL 工具或 BI 系统对列名有约定。例如：</p>
<ul>
<li>Grafana 默认识别 <code>timestamp</code> 作为时间轴</li>
<li>某些工业协议使用 <code>ts</code> 或 <code>collect_time</code></li>
</ul>
<pre><code>┌──────────────┐     ┌──────────────┐
│   IoTDB      │     │   Grafana    │
│  time 列     │ ──▶ │  期望        │
│  "time"      │     │  "timestamp" │
│              │     │              │
│  以前：需要  │     │  现在：直接  │
│  别名转换    │     │  定义匹配   │
└──────────────┘     └──────────────┘
</code></pre>
<p><strong>2. 多时间语义场景</strong></p>
<p>在某些工业场景中，存在多个时间概念：</p>
<ul>
<li><code>event_time</code> — 事件发生时间</li>
<li><code>collect_time</code> — 数据采集时间</li>
<li><code>process_time</code> — 处理时间</li>
</ul>
<p>自定义命名让语义更加清晰。</p>
<h3>配合 SQL 查看表/视图定义</h3>
<p>V2.0.8 同时新增了通过 SQL 查看已创建表和视图完整定义语句的能力，方便确认时间列等 schema 信息：</p>
<pre><code>-- 查看表的完整定义（推测性语法）
SHOW CREATE TABLE database1.table1;
</code></pre>
<hr />
<h2>变更四：Pipe 路径配置增强 — 精细化数据同步</h2>
<h3>变更前的限制</h3>
<p>V2.0.7 的 Pipe 数据同步在路径过滤上比较单一：</p>
<pre><code>-- V2.0.7：只能用 pattern 做前缀匹配
CREATE PIPE sync_pipe
WITH SOURCE (
  'source.pattern' = 'root.factory1.**'
)
</code></pre>
<p>这在需要排除特定设备或混合匹配时很不方便。</p>
<h3>V2.0.8 的三项增强</h3>
<h4>增强一：支持排除指定设备/测点</h4>
<pre><code>-- 同步 factory1 下所有数据，但排除调试设备
CREATE PIPE sync_pipe
WITH SOURCE (
  'source.pattern' = 'root.factory1.**',
  'source.exclusion' = 'root.factory1.debug_device.**'
)
</code></pre>
<h4>增强二：支持多个精确路径</h4>
<pre><code>-- 精确同步多个指定路径
CREATE PIPE sync_pipe
WITH SOURCE (
  'source.path' = 'root.factory1.device1.temperature, root.factory2.device3.pressure'
)
</code></pre>
<h4>增强三：pattern 与 path 混合使用</h4>
<pre><code>-- 混合使用前缀匹配和精确路径
CREATE PIPE sync_pipe
WITH SOURCE (
  'source.pattern' = 'root.factory1.**',
  'source.path' = 'root.factory2.device3.temperature'
)
</code></pre>
<h3>架构意义</h3>
<pre><code>┌─────────────────────────────────────────────────┐
│              数据同步路径控制演进                  │
│                                                  │
│  V2.0.6: 全量同步                                │
│          root.** ──────────────▶ 目标集群         │
│                                                  │
│  V2.0.7: 前缀过滤                                │
│          root.factory1.** ────▶ 目标集群          │
│                                                  │
│  V2.0.8: 精细化控制                               │
│          root.factory1.**                        │
│          - root.factory1.debug.**  (排除)         │
│          + root.factory2.device3   (精确追加)     │
│          ─────────────────────▶ 目标集群          │
└─────────────────────────────────────────────────┘
</code></pre>
<p>这对于多租户、跨区域同步场景非常实用。例如：同步生产数据到分析集群时，排除调试数据和临时测点，减少不必要的带宽和存储消耗。</p>
<h3>Release Notes 之外：Pipe 的深层改进</h3>
<p>翻阅 commit log，会发现 Pipe 模块在本版本中还有几项重要但未出现在 Release Notes 中的改动：</p>
<p><strong>1. TsFile 发送速率限制器</strong>（<a href="https://github.com/apache/iotdb/pull/16288">#16288</a>）</p>
<p>为 TsFile 的跨节点传输增加了 rate limiter。在大规模数据同步场景中（如历史数据迁移），无限速的传输可能压垮目标节点或打满网络带宽。这个改动让运维可以控制同步速度，避免影响线上业务。</p>
<p><strong>2. 全量同步拆分为历史 + 实时</strong>（<a href="https://github.com/apache/iotdb/pull/16250">#16250</a>）</p>
<p>此前一个 Pipe 既负责历史数据追赶，又负责实时增量同步。V2.0.8 将全量同步 Pipe 内部拆分为 history pipe 和 realtime pipe：</p>
<pre><code>┌─────────────────────────────────────────┐
│          V2.0.7: 单一 Pipe               │
│  历史数据追赶 + 实时增量  → 目标集群      │
│  (相互竞争资源，追赶期实时延迟高)         │
├─────────────────────────────────────────┤
│          V2.0.8: 拆分 Pipe               │
│  History Pipe ─→ 历史追赶   → 目标集群   │
│  Realtime Pipe ─→ 实时增量  → 目标集群   │
│  (独立调度，实时同步不受历史追赶影响)     │
└─────────────────────────────────────────┘
</code></pre>
<p><strong>3. OOM 检测与内存管控</strong>（<a href="https://github.com/apache/iotdb/pull/16119">#16119</a>、<a href="https://github.com/apache/iotdb/pull/16123">#16123</a>）</p>
<p>ConfigNode 新增了 Pipe 内存溢出检测逻辑，同时修复了表模型下构造 TabletBatch 导致内存膨胀的问题。这两项改动联合解决了大数据量同步场景下的 OOM 风险。</p>
<p><strong>4. Pipe 启停并发 Bug 修复</strong>（<a href="https://github.com/apache/iotdb/pull/16461">#16461</a>）</p>
<p>修复了快速执行 stop/start 操作时的并发竞态条件。在运维场景中（如脚本化批量管理 Pipe），这个 Bug 可能导致 Pipe 状态不一致。</p>
<hr />
<h2>隐藏在 commit log 中的重要变更</h2>
<p>官方 Release Notes 用 <code>...</code> 省略了不少内容。通过分析 V2.0.7 到 V2.0.8 之间的 <strong>250 个 commit</strong>，以下变更值得关注：</p>
<h3>性能优化</h3>
<p><strong>AlignedTVList InsertTablet 位图操作优化</strong>（<a href="https://github.com/apache/iotdb/pull/16199">#16199</a>）</p>
<p>优化了对齐时间序列写入时的 bitmap 标记操作。对于高频写入场景（如数千个测点同时写入），这个优化可以减少内存操作开销。</p>
<p><strong>Last Cache 组合查询优化</strong></p>
<p>对 <code>SELECT last(s1), last(s1, time), last(s2), last(s2, time)</code> 这类组合查询进行了专项优化，减少重复的 cache 查找开销。</p>
<p><strong>跳过无效 TTL 检查</strong>（<a href="https://github.com/apache/iotdb/pull/16110">#16110</a>）</p>
<p>当 data region 没有设置 TTL 且无 mods 文件时，跳过 TTL 检查逻辑。对于不使用 TTL 的场景，减少了不必要的检查开销。</p>
<p><strong>Load 模块优化</strong></p>
<ul>
<li>修复加载对齐 Chunk 时的 OOM 问题（<a href="https://github.com/apache/iotdb/pull/16132">#16132</a>）</li>
<li>减少不必要的 MD5 计算（<a href="https://github.com/apache/iotdb/pull/16141">#16141</a>）</li>
<li>支持流式加载 mem chunk，并将 filter/limit/offset 下推到 MemPointIterator</li>
</ul>
<h3>安全加固</h3>
<p>除了修复三个 CVE 漏洞之外，commit log 中还有多项安全相关改进：</p>
<table>
<thead>
<tr>
<th>改进项</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>CLI 密码隐藏</strong>（<a href="https://github.com/apache/iotdb/pull/16468">#16468</a>）</td>
<td>客户端命令行不再明文显示密码</td>
</tr>
<tr>
<td><strong>连接数限制</strong>（<a href="https://github.com/apache/iotdb/pull/16462">#16462</a>）</td>
<td>新增连接数限制功能，防止连接耗尽</td>
</tr>
<tr>
<td><strong>加密密钥管理</strong>（<a href="https://github.com/apache/iotdb/pull/16176">#16176</a>）</td>
<td>支持加密密钥的生成与 DataNode 退出时自动销毁</td>
</tr>
<tr>
<td><strong>SSL 连接校验</strong>（<a href="https://github.com/apache/iotdb/pull/16504">#16504</a>）</td>
<td>SSL 客户端连接非 SSL 服务端时抛出明确异常，而非静默失败</td>
</tr>
<tr>
<td><strong>密码策略修复</strong>（<a href="https://github.com/apache/iotdb/pull/16089">#16089</a>）</td>
<td>修复密码升级失败及密码历史记录问题</td>
</tr>
</tbody>
</table>
<h3>新增功能</h3>
<ul>
<li><strong>UDFT pattern_match</strong> — 基于 sketch 的时序相似性匹配算法，可用于时序模式检索</li>
<li><strong>数据类型默认压缩配置</strong>（<a href="https://github.com/apache/iotdb/pull/16117">#16117</a>） — 支持为每种数据类型设置默认压缩方式</li>
<li><strong>数据导出/导入增强</strong>（<a href="https://github.com/apache/iotdb/pull/16252">#16252</a>） — 支持进度追踪、超时配置和 mfs 参数</li>
</ul>
<h3>查询模块增强</h3>
<ul>
<li><strong>DataNode 节点列表展示</strong> — 新增可用 DataNode 的列表查询功能，方便运维监控</li>
<li><strong>查询延迟统计系统表</strong> — 在表模型中新增系统表，用于统计查询延迟信息，为性能调优提供数据支撑</li>
<li><strong>Python SessionDataset 优化</strong> — 支持将 TsBlock 批量转换为 DataFrame，减少 Python 客户端与 IoTDB 之间的数据转换开销</li>
</ul>
<h3>系统模块</h3>
<ul>
<li><strong>DataNode 连接状态系统表</strong> — 在表模型中展示 DataNode 节点连接状态，有助于快速定位集群通信问题</li>
</ul>
<h3>安全漏洞修复</h3>
<ul>
<li><strong>CVE-2025-12183</strong> — 建议尽快升级</li>
<li><strong>CVE-2025-66566</strong> — 建议尽快升级</li>
<li><strong>CVE-2025-11226</strong> — 建议尽快升级</li>
</ul>
<hr />
<h2>问题修复亮点</h2>
<p>本版本修复了多个影响数据查询准确性的关键 Bug：</p>
<table>
<thead>
<tr>
<th>问题</th>
<th>影响</th>
<th>严重程度</th>
</tr>
</thead>
<tbody>
<tr>
<td>last cache 命中后查询结果集为空</td>
<td>最新值查询返回错误</td>
<td>高</td>
</tr>
<tr>
<td>TVList 超 20w 点后倒序查询遗漏数据</td>
<td>大数据量查询不准确</td>
<td>高</td>
</tr>
<tr>
<td>canSkip 导致对齐序列查询超时</td>
<td>查询性能严重退化</td>
<td>高</td>
</tr>
<tr>
<td>LAST 查询别名未生效</td>
<td>结果展示不符预期</td>
<td>中</td>
</tr>
<tr>
<td>写入失败后立即删除操作失败</td>
<td>数据管理操作受阻</td>
<td>中</td>
</tr>
<tr>
<td>非默认时间列 TsFile 加载 NPE</td>
<td>数据导入异常</td>
<td>中</td>
</tr>
</tbody>
</table>
<p>其中 <strong>TVList 超 20w 点倒序查询遗漏数据</strong> 尤为关键 — 在工业场景中，单个序列超过 20 万点是很常见的（例如 1 秒采集频率的传感器，约 2.3 天的数据量）。如果你的业务涉及大量数据的倒序查询（如"最近 N 条"查询），建议优先升级。</p>
<p>此外，commit log 中还有更多未列入 Release Notes 的修复：</p>
<ul>
<li><strong>Tablet 编码连续 null 值时的 NPE</strong>（<a href="https://github.com/apache/iotdb/pull/16107">#16107</a>）— 写入包含大量空值的数据时可能触发</li>
<li><strong>非对齐序列创建时的 NPE</strong>（<a href="https://github.com/apache/iotdb/pull/16128">#16128</a>）— 对不存在的视图添加列时触发</li>
<li><strong>DataNode 异常退出失败</strong>（<a href="https://github.com/apache/iotdb/pull/16254">#16254</a>）— 异常处理失败导致 DN 无法正常退出</li>
<li><strong>C++ 客户端内存泄漏与异常修复</strong>（<a href="https://github.com/apache/iotdb/pull/16293">#16293</a>、<a href="https://github.com/apache/iotdb/pull/16284">#16284</a>）— 使用 ASAN 排查并修复</li>
</ul>
<hr />
<h2>生产环境升级建议</h2>
<h3>升级前检查清单</h3>
<pre><code># 1. 检查当前版本
./sbin/start-cli.sh -e "show version"

# 2. 确认是否使用了 AI 推理功能
grep -r "model" conf/iotdb-ai.properties 2&gt;/dev/null

# 3. 检查 Pipe 同步配置（路径参数语法可能需要适配）
./sbin/start-cli.sh -e "show pipes"

# 4. 备份
cp -r data/ data.backup.$(date +%Y%m%d)
cp -r conf/ conf.backup.$(date +%Y%m%d)
</code></pre>
<h3>按场景的升级建议</h3>
<table>
<thead>
<tr>
<th>使用场景</th>
<th>升级紧迫度</th>
<th>注意事项</th>
</tr>
</thead>
<tbody>
<tr>
<td>使用 AI 推理功能</td>
<td>推荐升级</td>
<td>新增 Chronos-2 和并发推理能力</td>
</tr>
<tr>
<td>大数据量倒序查询</td>
<td>建议尽快</td>
<td>修复 20w+ 点数据遗漏 Bug</td>
</tr>
<tr>
<td>使用 Pipe 数据同步</td>
<td>推荐升级</td>
<td>检查路径配置是否需要适配新语法</td>
</tr>
<tr>
<td>使用 last cache</td>
<td>建议尽快</td>
<td>修复结果集为空的关键 Bug</td>
</tr>
<tr>
<td>稳定运行无上述场景</td>
<td>择机升级</td>
<td>常规版本跟进</td>
</tr>
</tbody>
</table>
<hr />
<h2>总结</h2>
<h3>V2.0.8 反映了什么趋势？</h3>
<ol>
<li><strong>AI 原生化</strong> — 从"支持 AI"到"AI 可用于生产"（并发推理、多模型选择）</li>
<li><strong>Pipe 架构成熟化</strong> — 速率限制、历史/实时拆分、OOM 防护，数据同步从"能用"走向"好用"</li>
<li><strong>数据管理精细化</strong> — TIME 列命名、Pipe 路径排除，都是面向真实生产场景的打磨</li>
<li><strong>安全纵深防御</strong> — CVE 修复之外，密码隐藏、连接限制、密钥管理、SSL 校验形成多层防线</li>
<li><strong>可观测性增强</strong> — 新增多个系统表，让运维和性能调优有据可依</li>
</ol>
<h3>与 V2.0.7 的对比</h3>
<table>
<thead>
<tr>
<th>维度</th>
<th>V2.0.7</th>
<th>V2.0.8</th>
</tr>
</thead>
<tbody>
<tr>
<td>主题</td>
<td>安全加固</td>
<td>AI 增强 + Pipe 架构升级 + 数据管理优化</td>
</tr>
<tr>
<td>commit 数量</td>
<td>~120</td>
<td>250</td>
</tr>
<tr>
<td>破坏性变更</td>
<td>RPC 地址默认值变更</td>
<td>无明显破坏性变更</td>
</tr>
<tr>
<td>升级风险</td>
<td>中（需检查网络配置）</td>
<td>低（向后兼容）</td>
</tr>
<tr>
<td>重点关注</td>
<td>集群部署配置</td>
<td>AI 功能、Pipe 稳定性、查询准确性修复</td>
</tr>
</tbody>
</table>
<hr />
<h2>参考资料</h2>
<ul>
<li><a href="https://github.com/apache/iotdb/releases/tag/v2.0.8">IoTDB V2.0.8 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/compare/v2.0.7...v2.0.8">V2.0.7 → V2.0.8 完整 Changelog</a>（250 commits）</li>
<li><a href="https://iotdb.apache.org/Download/">IoTDB 官网下载页</a></li>
<li><a href="https://mp.weixin.qq.com/s/wW_k9ZlxNGmVyG_rFNuYBA">IoTDB 公众号发布说明</a></li>
<li><a href="https://github.com/amazon-science/chronos-forecasting">Chronos-2 论文与代码</a></li>
<li><a href="https://hub.docker.com/r/apache/iotdb">Docker 镜像</a></li>
<li><a href="https://search.maven.org/search?q=3Dg:org.apache.iotdb">Maven 仓库</a></li>
<li><a href="https://pypi.org/project/apache-iotdb/">Python API</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[除了 OpenClaw，你还有另外一种选择]]></title>
            <link>https://critas.wang/posts/chatcc-alternative-to-openclaw/</link>
            <guid isPermaLink="false">https://critas.wang/posts/chatcc-alternative-to-openclaw/</guid>
            <pubDate>Thu, 12 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[ChatCC：通过飞书远程操控 Claude Code 的轻量开发工具，与 OpenClaw 的定位对比和使用指南。]]></description>
            <content:encoded><![CDATA[<blockquote>
<p>项目地址：<a href="https://github.com/CritasWang/chat-cc">https://github.com/CritasWang/chat-cc</a></p>
</blockquote>
<hr />
<h2>AI 编程工具的两种思路</h2>
<p>当我们谈论 AI 辅助编程工具时，大多数人第一时间想到的是 IDE 插件——安装、授权、在编辑器里调用。这条路线已经相当成熟：GitHub Copilot、Cursor、Windsurf，都是典型代表。</p>
<p>但还有另一种思路：<strong>不动 IDE，通过即时通讯工具远程操控 AI 编程助手</strong>。</p>
<p>你在会议室开会，手机弹出一条飞书消息，随手输入 <code>/ask 帮我把用户登录接口改成 JWT 认证</code>，几十秒后，Claude Code 已经在你的服务器上完成了修改。你甚至不需要打开笔记本电脑。</p>
<p>这两种思路没有高下之分，解决的是不同场景下的不同问题。今天，我们来聊聊第二种思路的一个具体实现——<strong>ChatCC</strong>。</p>
<hr />
<h2>OpenClaw 是什么</h2>
<p>在展开 ChatCC 之前，先简单说说 OpenClaw。</p>
<p><a href="https://github.com/openclaw/openclaw">OpenClaw</a> 是一个运行在本地设备上的通用个人 AI 助手，支持 20+ 消息平台（WhatsApp、Telegram、Slack、Discord、飞书等），可接入 ChatGPT、Claude、Gemini 等多个模型，提供日常 AI 对话、语音交互、技能系统扩展等能力。</p>
<p>如果你需要一个跨平台的统一 AI 助手，OpenClaw 是一个不错的选择。</p>
<p>但如果你的需求是：<strong>远程控制本地 Claude Code、移动端操作、不依赖特定 IDE、与团队飞书工作流深度整合</strong>——那么 ChatCC 可能更适合你。</p>
<hr />
<h2>ChatCC 是什么</h2>
<p><a href="https://github.com/CritasWang/chat-cc">ChatCC</a> 是一个用 Go 编写的飞书机器人服务。<strong>Chat</strong>（聊天）+ <strong>CC</strong>（Claude Code + Command），名字本身就概括了它的核心理念：</p>
<blockquote>
<p><strong>通过飞书消息远程操控 Claude Code 和本地程序。</strong></p>
</blockquote>
<p>ChatCC 运行在你本地或服务器上，通过飞书开放平台的 WebSocket 长连接与飞书云端保持实时通信。当你在飞书中 @机器人 或发送命令消息时，ChatCC 接收到请求，调用本地安装的 Claude Code 执行任务，再将结果回复给你。</p>
<p>整个过程<strong>不需要公网 IP</strong>，不需要开放任何防火墙端口，WebSocket 长连接从内网主动发出，对网络环境没有特殊要求。</p>
<hr />
<h2>核心特性详解</h2>
<h3>1. 双模式 Claude Code 集成</h3>
<p>ChatCC 提供两种截然不同的交互模式，满足不同场景需求：</p>
<p><strong>无状态模式（<code>/ask</code>）</strong></p>
<pre><code>/ask 解释一下这个项目的目录结构
/ask --cwd /path/to/project 帮我写单元测试
/ask @server 查看最近的错误日志
</code></pre>
<p>每次调用独立执行，底层使用 <code>claude -p</code> 一次性调用。适合快速查询、代码解释、单次任务。默认超时 50 分钟，足以处理复杂的代码分析任务。</p>
<p><strong>持久会话模式（<code>/session</code> + <code>/s</code>）</strong></p>
<pre><code>/session start @myproject    # 启动 tmux 持久会话
/s 先看看 README              # 发送消息到活跃会话
/s 现在帮我重构 auth 模块      # 继续上下文对话
/session status               # 查看当前会话详情
/session list                 # 列出所有活跃会话
/session stop                 # 关闭会话
</code></pre>
<p>持久会话模式基于 tmux，Claude Code 在 tmux 窗格中持续运行，保留完整的对话上下文。适合需要多轮交互的复杂开发任务。</p>
<p>两种模式可以灵活切换，非命令消息会自动路由：有活跃 tmux 会话时发给会话，否则作为 <code>/ask</code> 处理。</p>
<h3>2. 交互式输入智能处理</h3>
<p>当 Claude Code 在会话中遇到交互式提示（如确认操作、yes/no 问题等）时，ChatCC 会自动检测并提示你：</p>
<pre><code>⚠️ 检测到交互式提示，Claude Code 正在等待输入。
💡 请使用 /s 命令发送您的响应。
</code></pre>
<p>系统能识别 <code>(y/n)</code>、<code>[yes/no]</code>、<code>continue?</code>、<code>press enter</code> 等常见交互模式，你只需通过 <code>/s yes</code> 或 <code>/s n</code> 回应即可。这个功能让远程操控 Claude Code 变得更加顺畅——你不会因为错过一个确认提示而导致任务卡住。</p>
<h3>3. Claude Code Hooks 双向回调</h3>
<p>ChatCC 在 9876 端口启动一个 HTTP 服务，提供 <code>/notify</code> 和 <code>/health</code> 端点。</p>
<p>这意味着 Claude Code 在执行过程中可以主动向飞书推送消息——文件修改、任务完成、重要决策点……你不需要盯着终端，飞书消息会主动告诉你 Claude Code 正在做什么。</p>
<p>在 Claude Code 配置 Hooks：</p>
<pre><code>{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {
            "type": "command",
            "command": "curl -sS http://localhost:9876/notify -H 'Content-Type: application/json' -d '{\"event\":\"file_changed\",\"message\":\"Claude 修改了文件\",\"chat_id\":\"oc_xxx\"}'"
          }
        ]
      }
    ]
  }
}
</code></pre>
<p>Hook HTTP API 支持 POST 通知和 GET 健康检查：</p>
<pre><code>POST http://localhost:9876/notify
Content-Type: application/json

{
  "event": "task_complete",
  "message": "任务已完成: 重构了认证模块",
  "chat_id": "oc_xxx"       // 可选，指定推送到哪个飞书聊天
}
</code></pre>
<p>这是真正的双向通信：你控制 Claude Code，Claude Code 也能主动汇报进度。</p>
<h3>4. 安全控制体系</h3>
<p>对于一个能远程执行代码的工具，安全设计至关重要。ChatCC 提供了多层安全控制：</p>
<ul>
<li><strong>用户白名单</strong>：只有配置中列出的飞书用户 ID 才能使用机器人</li>
<li><strong>群组白名单</strong>：可限制机器人只在指定群聊中响应</li>
<li><strong>Shell 命令白名单</strong>：<code>/shell</code> 命令只能执行预先配置的允许命令</li>
<li><strong>危险模式开关</strong>：<code>/danger on|off</code> 动态控制 Claude Code 的权限绕过行为</li>
<li><strong>嵌套会话保护</strong>：自动过滤 <code>CLAUDECODE</code>、<code>ANTHROPIC_*</code> 等环境变量，避免在 Claude Code 环境中启动子进程时出现嵌套检测错误</li>
</ul>
<p>即便机器人 Token 泄露，未授权用户也无法通过机器人执行任何操作。</p>
<h3>5. 长消息智能分块</h3>
<p>Claude Code 的输出经常很长。ChatCC 会自动将超过 3500 字符的消息分块发送，避免消息截断导致信息丢失。分块时会智能选择段落、句子边界，确保内容完整性，每条分块消息标注序号（如 [1/3], [2/3], [3/3]）。</p>
<p>分块大小可自定义：</p>
<pre><code>max_chunk_size: 3500    # 默认 3500 字符
</code></pre>
<h3>6. 后台运行与日志管理</h3>
<p>ChatCC 编译为单个二进制文件，内置完整的守护进程支持：</p>
<pre><code>chatcc start --config config.local.yaml    # 后台启动
chatcc stop                                 # 停止
chatcc restart --config config.local.yaml   # 重启
chatcc status                               # 查看状态
chatcc console --config config.local.yaml   # 前台运行（调试用）
</code></pre>
<p>日志按天滚动，自动 gzip 压缩历史日志（<code>logs/chatcc-YYYY-MM-DD.log.gz</code>），不需要额外配置 logrotate。<code>console</code> 模式日志直接输出到终端，方便调试。</p>
<h3>7. 热重载与项目别名</h3>
<p>修改配置文件后，发送 <code>/reload</code> 命令，配置立即生效，无需重启服务、无需重连飞书。</p>
<p>项目别名让你不需要记忆绝对路径：</p>
<pre><code>projects:
  server: "/home/user/projects/backend"
  devops: "/home/user/infrastructure"
  web: "/home/user/projects/frontend"
</code></pre>
<p>配置好后，直接用 <code>/ask @server</code> 或 <code>/session start @devops</code> 即可。使用 <code>/project</code>（或 <code>/p</code>）命令可以随时查看所有已配置的项目别名。</p>
<hr />
<h2>完整命令列表</h2>
<table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
<th>示例</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>/ask &lt;提示词&gt;</code></td>
<td>Claude Code 无状态问答</td>
<td><code>/ask 帮我看看有什么文件</code></td>
</tr>
<tr>
<td><code>/ask --cwd &lt;目录&gt; &lt;提示词&gt;</code></td>
<td>指定工作目录</td>
<td><code>/ask --cwd /path/to/project 分析结构</code></td>
</tr>
<tr>
<td><code>/ask @别名 &lt;提示词&gt;</code></td>
<td>用项目别名</td>
<td><code>/ask @server 看看迁移方案</code></td>
</tr>
<tr>
<td><code>/session start [目录]</code></td>
<td>启动 tmux 持久会话</td>
<td><code>/session start @webapp</code></td>
</tr>
<tr>
<td><code>/session status</code></td>
<td>查看当前会话详情</td>
<td><code>/session status</code></td>
</tr>
<tr>
<td><code>/session list</code></td>
<td>列出所有活跃会话</td>
<td><code>/session list</code></td>
</tr>
<tr>
<td><code>/session kill &lt;会话名&gt;</code></td>
<td>终止指定会话</td>
<td><code>/session kill cc-chat-xxx</code></td>
</tr>
<tr>
<td><code>/session stop</code></td>
<td>关闭当前会话</td>
<td><code>/session stop</code></td>
</tr>
<tr>
<td><code>/s &lt;消息&gt;</code></td>
<td>发送到活跃会话</td>
<td><code>/s 帮我重构这个函数</code></td>
</tr>
<tr>
<td><code>/shell &lt;命令&gt;</code></td>
<td>执行白名单 shell 命令</td>
<td><code>/shell docker ps</code></td>
</tr>
<tr>
<td><code>/project</code> 或 <code>/p</code></td>
<td>查看已配置的项目别名</td>
<td><code>/project</code></td>
</tr>
<tr>
<td><code>/status</code></td>
<td>查看系统状态和活跃会话</td>
<td><code>/status</code></td>
</tr>
<tr>
<td><code>/danger on|off</code></td>
<td>切换权限绕过模式</td>
<td><code>/danger on</code></td>
</tr>
<tr>
<td><code>/reload</code></td>
<td>热重载配置文件</td>
<td><code>/reload</code></td>
</tr>
<tr>
<td><code>/help [命令]</code></td>
<td>帮助信息</td>
<td><code>/help ask</code></td>
</tr>
</tbody>
</table>
<p><strong>非命令消息</strong>：如有活跃 tmux 会话则发送到会话，否则等同 <code>/ask</code>。</p>
<hr />
<h2>ChatCC vs OpenClaw 对比</h2>
<p>理解两个工具各自的定位和优势，有助于做出正确选择。</p>
<table>
<thead>
<tr>
<th>维度</th>
<th>OpenClaw</th>
<th>ChatCC</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>定位</strong></td>
<td>通用个人 AI 助手，支持多平台</td>
<td>专注飞书的 Claude Code 远程控制网关</td>
</tr>
<tr>
<td><strong>核心功能</strong></td>
<td>多模型 AI 对话（ChatGPT/Claude/Gemini）</td>
<td>Claude Code 专用执行环境（本地开发工具）</td>
</tr>
<tr>
<td><strong>消息平台</strong></td>
<td>20+ 平台（WhatsApp/Telegram/Slack 等）</td>
<td>仅飞书（深度集成）</td>
</tr>
<tr>
<td><strong>技术栈</strong></td>
<td>Node.js</td>
<td>Go（单二进制部署）</td>
</tr>
<tr>
<td><strong>本地执行</strong></td>
<td>主要调用 AI API</td>
<td>直接在本地执行 Claude Code（tmux 持久会话）</td>
</tr>
<tr>
<td><strong>配置复杂度</strong></td>
<td>多平台 + 多模型认证</td>
<td>仅需飞书 app_id/app_secret</td>
</tr>
<tr>
<td><strong>目标用户</strong></td>
<td>需要跨平台 AI 助手的个人用户</td>
<td>需要远程控制开发环境的开发者</td>
</tr>
</tbody>
</table>
<h3>选择 ChatCC 的场景</h3>
<ul>
<li>你需要通过飞书<strong>远程控制本地 Claude Code</strong>，访问本地文件系统，执行代码分析和自动化任务</li>
<li>你的团队深度使用飞书作为协作工具，希望<strong>开发工作流与飞书打通</strong></li>
<li>你在<strong>企业内网环境</strong>工作，需要从外部安全访问内网开发机</li>
<li>你希望在移动端或非编码场景（会议、外出）也能操控 Claude Code</li>
<li>你追求<strong>轻量部署</strong>——单平台、单二进制、5 分钟部署完成</li>
<li>你管理多个服务器/项目，希望通过统一的飞书界面远程控制</li>
</ul>
<h3>选择 OpenClaw 的场景</h3>
<ul>
<li>你需要<strong>跨平台统一 AI 助手</strong>——在 WhatsApp、Telegram、Slack 等多平台使用同一个 AI</li>
<li>你需要<strong>多模型 AI 对话</strong>——同时使用 OpenAI、Claude、Gemini，支持故障转移和自动切换</li>
<li>你需要<strong>语音和多模态</strong>交互能力</li>
<li>团队熟悉 Node.js/TypeScript 生态，希望二次开发</li>
</ul>
<p>两者并不互斥。完全可以用 OpenClaw 做日常 AI 助手处理通用对话，同时在服务器上运行 ChatCC 处理 Claude Code 相关的开发任务：</p>
<pre><code>WhatsApp/Telegram ──→ OpenClaw ──→ 日常 AI 对话
飞书             ──→ ChatCC   ──→ 远程控制 Claude Code
</code></pre>
<p>各司其职，互不干扰。</p>
<hr />
<h2>快速上手</h2>
<h3>第一步：创建飞书自建应用</h3>
<ol>
<li>登录<a href="https://open.feishu.cn/">飞书开放平台</a>，创建一个企业自建应用</li>
<li>添加「机器人」能力</li>
<li>在「权限管理」中开启以下权限：
<ul>
<li><code>im:message</code>（接收消息）</li>
<li><code>im:message:send_as_bot</code>（发送消息）</li>
<li><code>im:message:patch</code>（更新消息）</li>
</ul>
</li>
<li>在「事件订阅」中选择 <strong>WebSocket 模式</strong>，订阅 <code>im.message.receive_v1</code> 事件</li>
<li>发布应用版本</li>
<li>获取 App ID 和 App Secret</li>
</ol>
<h3>第二步：安装 Claude Code</h3>
<pre><code>npm install -g @anthropic-ai/claude-code
</code></pre>
<p>确保 <code>claude</code> 命令可在 PATH 中访问。</p>
<h3>第三步：安装 ChatCC</h3>
<pre><code>git clone https://github.com/CritasWang/chat-cc.git
cd chat-cc
go build -o chatcc .
</code></pre>
<p>或直接下载发布版二进制文件。</p>
<h3>第四步：配置</h3>
<pre><code>cp config.yaml config.local.yaml
</code></pre>
<p>编辑 <code>config.local.yaml</code>：</p>
<pre><code>feishu:
  app_id: "cli_xxxxxxxxxxxxxxxx"
  app_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

security:
  allowed_users:
    - "your_feishu_user_id"
  allowed_shells:
    - "git status"
    - "git log --oneline -10"
    - "docker ps"

# 超时配置（分钟）
claude_ask_timeout: 50
claude_session_timeout: 50

projects:
  server: "/home/user/backend"
  web: "/home/user/frontend"
</code></pre>
<p>也支持环境变量方式配置：</p>
<pre><code>export FEISHU_APP_ID="cli_xxx"
export FEISHU_APP_SECRET="xxx"
</code></pre>
<h3>第五步：启动</h3>
<pre><code>./chatcc start --config config.local.yaml
./chatcc status
</code></pre>
<p>在飞书中找到你的机器人，发送 <code>/help</code>，开始使用。</p>
<hr />
<h2>进阶用法</h2>
<h3>配置 Claude Code Hooks 回调</h3>
<p>在 <code>~/.claude/settings.json</code> 中配置 Hooks，让 Claude Code 主动回报进度：</p>
<pre><code>{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit|Bash",
        "hooks": [
          {
            "type": "command",
            "command": "curl -sS http://localhost:9876/notify -H 'Content-Type: application/json' -d '{\"event\":\"file_changed\",\"message\":\"Claude 修改了文件\",\"chat_id\":\"oc_xxx\"}'"
          }
        ]
      }
    ]
  }
}
</code></pre>
<p>每次 Claude Code 完成文件写入或执行命令后，你的飞书会收到通知。</p>
<h3>群聊协作模式</h3>
<p>将机器人加入团队群聊，配置群聊 ID 到白名单，团队成员都可以 @机器人 发起任务。任务执行过程和结果对整个群组可见——这在结对编程或代码 Review 场景中非常有用。</p>
<h3>结合 tmux 调试</h3>
<p>ChatCC 的会话模式本质上管理的是 tmux 会话，你也可以直接登录服务器查看 tmux 中 Claude Code 的实时输出，双向调试非常方便：</p>
<pre><code># 通过 /session list 查看会话名
tmux attach -t cc-chat-xxx
</code></pre>
<p>同时 ChatCC 支持 <code>console</code> 前台模式，日志直接输出到终端，便于排查问题。</p>
<hr />
<h2>总结</h2>
<p>OpenClaw 和 ChatCC 代表了两种不同的设计哲学：</p>
<ul>
<li><strong>OpenClaw</strong>：通用 AI 助手，跨平台统一入口，覆盖多种模型和交互方式</li>
<li><strong>ChatCC</strong>：专注开发者场景，让飞书成为 Claude Code 的远程控制台</li>
</ul>
<p>如果你的工作流已经深度整合飞书，如果你需要远程控制开发环境，如果你想让 AI 编程任务变得可观测、可协作——不妨试试 ChatCC。</p>
<p>它的安装部署只需 5 分钟，单二进制文件、零依赖（除了 Go 和 Claude Code），代码完全开源可审计，WebSocket 架构意味着你不需要改动任何网络配置。对于个人开发者和小团队来说，这是一个轻量、灵活、实用的选择。</p>
<blockquote>
<p>项目地址：<a href="https://github.com/CritasWang/chat-cc">https://github.com/CritasWang/chat-cc</a></p>
</blockquote>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB 新版本发布：V2.0.7 与 V1.3.7 功能解析与升级注意事项]]></title>
            <link>https://critas.wang/posts/iotdb-v207-v137-overview/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-v207-v137-overview/</guid>
            <pubDate>Wed, 11 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB V2.0.7 和 V1.3.7 同步发布，本文梳理核心变更、升级踩坑点和版本选择建议。]]></description>
            <content:encoded><![CDATA[<h2>概览</h2>
<p>2026 年 3 月 4 日，Apache IoTDB 同时发布了 V2.0.7 和 V1.3.7。两个版本共享了一组相同的安全加固措施，但 V1.3.7 还额外包含了大量 bug 修复和性能优化（48 个提交 vs V2.0.7 的 16 个）。</p>
<p>本文从实际 <a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">GitHub Release</a> 和提交记录出发，梳理以下内容：</p>
<ol>
<li>两个版本的核心变更</li>
<li><strong>RPC 地址变更</strong> — 升级最大的坑</li>
<li>其他值得关注的改动</li>
<li>版本选择与升级建议</li>
</ol>
<blockquote>
<p>参考来源：<a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">Apache IoTDB 公众号发布说明</a>、<a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">V2.0.7 Release Notes</a>、<a href="https://github.com/apache/iotdb/releases/tag/v1.3.7">V1.3.7 Release Notes</a></p>
</blockquote>
<hr />
<h2>两个版本共享的核心变更</h2>
<p>V2.0.7 和 V1.3.7 包含相同的安全加固和配置调整：</p>
<table>
<thead>
<tr>
<th>变更项</th>
<th>说明</th>
<th>影响</th>
</tr>
</thead>
<tbody>
<tr>
<td>RPC 默认地址改为 127.0.0.1</td>
<td>客户端 RPC 服务默认只监听本地回环</td>
<td><strong>集群部署必须修改配置</strong></td>
</tr>
<tr>
<td>移除高风险 RPC 接口</td>
<td>删除存在安全隐患的 RPC 接口</td>
<td>提升安全性</td>
</tr>
<tr>
<td>移除 JEXL 函数</td>
<td>移除 Tree 模式下的内置 JEXL 函数</td>
<td>使用 JEXL 的查询需改写</td>
</tr>
<tr>
<td>内部服务绑定优化</td>
<td>内部服务绑定到 <code>dn_internal_address</code> 而非默认地址</td>
<td>网络分层更安全</td>
</tr>
<tr>
<td>Pipe 命名检查</td>
<td>创建 Pipe 时增加命名合法性校验</td>
<td>防止非法字符导致运行时错误</td>
</tr>
<tr>
<td>分区表 TTL 删除修复</td>
<td>修复仅 DB 级别 TTL 生效且使用最大值的问题</td>
<td>Tree 模式下的 TTL 行为更准确</td>
</tr>
</tbody>
</table>
<hr />
<h2>RPC 地址变更：升级最大的坑</h2>
<p>这是本次升级<strong>最需要注意的变更</strong>。</p>
<h3>变更内容</h3>
<pre><code># V2.0.6 / V1.3.6 及之前
dn_rpc_address=0.0.0.0    # 监听所有网络接口

# V2.0.7 / V1.3.7
dn_rpc_address=127.0.0.1  # 仅监听本地回环
</code></pre>
<p>对应的 PR：<a href="https://github.com/apache/iotdb/pull/17060">#17060 Change default dn rpc address</a></p>
<h3>为什么要改</h3>
<p>这是一个 <strong>Secure by Default</strong> 设计决策。当 <code>rpcAddress=0.0.0.0</code> 时，数据库会监听所有网络接口（包括公网接口），在未配置防火墙的环境下存在安全风险。改为 <code>127.0.0.1</code> 后，用户需要显式配置才能开放外部访问。</p>
<h3>对不同部署场景的影响</h3>
<p><strong>单机部署</strong> — 无影响，本地 CLI 连接 <code>127.0.0.1:6667</code> 正常工作。</p>
<p><strong>集群部署</strong> — <strong>必须修改配置</strong>，否则其他节点和远程客户端无法连接。</p>
<pre><code># 错误配置（升级后远程无法连接）
dn_rpc_address=127.0.0.1

# 正确配置（绑定实际 IP）
dn_rpc_address=192.168.1.10
dn_internal_address=192.168.1.10
</code></pre>
<p><strong>Docker 部署</strong> — 容器内需要保持监听所有接口：</p>
<pre><code>services:
  iotdb:
    image: apache/iotdb:2.0.7
    environment:
      - IOTDB_DN_RPC_ADDRESS=0.0.0.0
</code></pre>
<h3>常见故障现象</h3>
<p>升级后如果出现以下错误，大概率是 RPC 地址配置问题：</p>
<pre><code>Error: Connection refused
</code></pre>
<p>从其他机器执行 <code>./sbin/start-cli.sh -h &lt;目标IP&gt;</code> 无法连接。</p>
<p><strong>排查方法：</strong></p>
<pre><code># 检查实际监听地址
ss -tlnp | grep 6667

# 如果显示 127.0.0.1:6667，说明需要修改配置
# 如果显示 0.0.0.0:6667 或实际IP:6667，说明配置正确
</code></pre>
<hr />
<h2>内部服务绑定优化</h2>
<p>对应 PR：<a href="https://github.com/apache/iotdb/pull/16717">#16717 Bind real config address for Thrift and Raft services</a></p>
<p>此前内部 Thrift 和 Raft 服务可能绑定到默认地址（如 <code>0.0.0.0</code>），导致内部通信接口暴露在不必要的网络接口上。修改后，这些服务会绑定到 <code>dn_internal_address</code> 指定的地址，实现客户端流量与内部集群通信的网络分层：</p>
<ul>
<li><code>dn_rpc_address</code> — 客户端连接入口</li>
<li><code>dn_internal_address</code> — 集群节点间通信</li>
</ul>
<hr />
<h2>移除 JEXL 函数</h2>
<p>对应 PR：<a href="https://github.com/apache/iotdb/pull/17092">#17092 Remove built-in jexl function in tree mode</a></p>
<p>JEXL（Java Expression Language）曾用于动态执行表达式，但存在代码注入风险且使用率低。移除后，原有的 JEXL 查询需要改写：</p>
<table>
<thead>
<tr>
<th>原 JEXL 用法</th>
<th>替代方案</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>JEXL('value * 2')</code></td>
<td>内置算术：<code>value * 2</code></td>
</tr>
<tr>
<td><code>JEXL('sin(value)')</code></td>
<td>内置函数：<code>sin(value)</code></td>
</tr>
<tr>
<td>复杂业务逻辑</td>
<td>自定义 UDF（Java 编译）</td>
</tr>
</tbody>
</table>
<p><strong>升级前建议检查</strong>：</p>
<pre><code># 扫描查询日志中的 JEXL 使用
grep -i "JEXL" /path/to/query/logs/*.log
</code></pre>
<hr />
<h2>V1.3.7 额外的改进</h2>
<p>V1.3.7 除了上述共享变更外，还包含大量 bug 修复和性能优化：</p>
<h3>内存管理改进</h3>
<ul>
<li>修复加载大量 TsFile 时的 GC 问题（<a href="https://github.com/apache/iotdb/pull/16853">#16853</a>）— 改为分批加载，避免同时加载所有文件资源</li>
<li>修复 IoTConsensus 队列中的内存泄漏（<a href="https://github.com/apache/iotdb/pull/16966">#16966</a>）</li>
<li>修复查询排序索引的内存预留问题（<a href="https://github.com/apache/iotdb/pull/16959">#16959</a>）</li>
<li>修复 TVList 所有权转移时的内存释放异常（<a href="https://github.com/apache/iotdb/pull/16943">#16943</a>）</li>
</ul>
<h3>查询引擎修复</h3>
<ul>
<li>修复 Last 查询排序问题（<a href="https://github.com/apache/iotdb/pull/16956">#16956</a>）</li>
<li>修复 MemTable 查询 bug（<a href="https://github.com/apache/iotdb/pull/16970">#16970</a>）</li>
<li>修复插入全 null 对齐 Tablet 并 flush 后的查询错误（<a href="https://github.com/apache/iotdb/pull/17041">#17041</a>）</li>
<li>修复 overlap unpack 在 endTime 为哨兵值时的错误（<a href="https://github.com/apache/iotdb/pull/16993">#16993</a>）</li>
</ul>
<h3>性能优化</h3>
<ul>
<li>优化 MemTable Region Scan 效率（<a href="https://github.com/apache/iotdb/pull/16891">#16891</a>, <a href="https://github.com/apache/iotdb/pull/16979">#16979</a>）</li>
<li>优化 DeviceViewIntoOperator 为 Pipeline 风格（<a href="https://github.com/apache/iotdb/pull/16980">#16980</a>）</li>
<li>移除 Schema Cache 中无用的 first key（<a href="https://github.com/apache/iotdb/pull/16881">#16881</a>）</li>
</ul>
<h3>Pipe 功能改进</h3>
<ul>
<li>支持 Pattern Pruning 和冗余路径移除（<a href="https://github.com/apache/iotdb/pull/17059">#17059</a>）</li>
<li>修复批量内存对 Pipe 内存管理不可见的 bug（<a href="https://github.com/apache/iotdb/pull/16962">#16962</a>）</li>
<li>优化 Pipe 性能，禁用部分无用逻辑（<a href="https://github.com/apache/iotdb/pull/16916">#16916</a>）</li>
<li>DataNode 首次启动时清理 Active Load 监听目录（<a href="https://github.com/apache/iotdb/pull/16854">#16854</a>）</li>
</ul>
<hr />
<h2>V2.0.6 中已修复的 CVE</h2>
<p>以下安全漏洞已在 <strong>V2.0.6/V1.3.6</strong> 中修复（非本次版本）：</p>
<ul>
<li><strong>CVE-2025-12183</strong> — 安全漏洞修复</li>
<li><strong>CVE-2025-66566</strong> — 安全漏洞修复</li>
<li><strong>CVE-2025-11226</strong> — 安全漏洞修复</li>
</ul>
<p>如果你还在使用 V2.0.5/V1.3.5 或更早版本，建议直接升级到最新版本以同时获得 CVE 修复和本次安全加固。</p>
<hr />
<h2>版本选择建议</h2>
<table>
<thead>
<tr>
<th>场景</th>
<th>推荐版本</th>
<th>理由</th>
</tr>
</thead>
<tbody>
<tr>
<td>新项目</td>
<td><strong>V2.0.7</strong></td>
<td>1.3.x 已停止新功能开发</td>
</tr>
<tr>
<td>1.3.x 生产环境</td>
<td><strong>V1.3.7</strong>（过渡）+ 规划迁移 2.x</td>
<td>获取安全修复，同时准备迁移</td>
</tr>
<tr>
<td>需要 Table 模型</td>
<td><strong>V2.0.7</strong></td>
<td>仅 2.x 支持 Tree + Table 双模型</td>
</tr>
<tr>
<td>需要 MATCH RECOGNIZE</td>
<td><strong>V2.0.7</strong></td>
<td>仅 2.x 支持</td>
</tr>
<tr>
<td>测试/开发环境</td>
<td><strong>V2.0.7</strong></td>
<td>使用最新版本</td>
</tr>
</tbody>
</table>
<p><strong>核心建议：</strong> 1.3.x 已进入维护模式，仅接收安全和关键 bug 修复。除非有无法克服的限制，否则应该选择 2.x 或规划迁移。</p>
<hr />
<h2>升级检查清单</h2>
<h3>升级前</h3>
<pre><code># 1. 检查当前 RPC 配置
grep -E "rpc_address|internal_address" conf/iotdb-conf.properties

# 2. 检查 JEXL 使用情况
grep -i "JEXL" /path/to/query/logs/*.log

# 3. 检查集群状态
./sbin/start-cli.sh
&gt; show datanodes;
&gt; show confignodes;

# 4. 备份配置和数据
cp -r conf/ conf.backup.$(date +%Y%m%d)
cp -r data/ data.backup.$(date +%Y%m%d)
</code></pre>
<h3>升级时</h3>
<pre><code># 1. 先修改配置（集群部署必做）
vim conf/iotdb-conf.properties
# dn_rpc_address=&lt;本机实际IP&gt;
# dn_internal_address=&lt;本机实际IP&gt;

# 2. 停止服务
./sbin/stop-datanode.sh

# 3. 替换二进制文件

# 4. 启动服务
./sbin/start-datanode.sh
</code></pre>
<h3>升级后</h3>
<pre><code># 1. 验证连接
./sbin/start-cli.sh -h &lt;实际IP&gt;

# 2. 检查集群节点状态
&gt; show datanodes;

# 3. 检查日志
tail -100 log/iotdb.log | grep -E "ERROR|WARN"
</code></pre>
<hr />
<h2>延伸阅读</h2>
<ul>
<li><a href="/posts/iotdb-v207-release-notes/">深度解析 Apache IoTDB V2.0.7：安全加固与架构优化</a> — V2.0.7 架构决策深度分析</li>
<li><a href="/posts/iotdb-v137-lts-analysis/">Apache IoTDB V1.3.7 版本解析</a> — 1.3.x 用户的升级指南</li>
<li><a href="/posts/iotdb-migration-13-to-2x/">Apache IoTDB 从 1.3.x 迁移到 2.x 完整指南</a> — 迁移实战步骤</li>
</ul>
<h2>参考资料</h2>
<ul>
<li><a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">IoTDB V2.0.7 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/releases/tag/v1.3.7">IoTDB V1.3.7 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/compare/v2.0.6...v2.0.7">V2.0.6 vs V2.0.7 完整变更对比</a></li>
<li><a href="https://github.com/apache/iotdb/compare/v1.3.6...v1.3.7">V1.3.6 vs V1.3.7 完整变更对比</a></li>
<li><a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">IoTDB 公众号发布说明</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB 从 1.3.x 迁移到 2.x 完整指南]]></title>
            <link>https://critas.wang/posts/iotdb-migration-13-to-2x/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-migration-13-to-2x/</guid>
            <pubDate>Thu, 05 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB 从 1.3.x 迁移到 2.x 的完整实战指南，包括迁移评估、方案选择、数据迁移、应用适配和验证流程。]]></description>
            <content:encoded><![CDATA[<h2>为什么必须迁移到 2.x？</h2>
<p><strong>先说结论：1.3.x 已进入维护模式，2.x 才是 IoTDB 的未来。</strong></p>
<h3>版本现状对比</h3>
<table>
<thead>
<tr>
<th>维度</th>
<th>1.3.x</th>
<th>2.x</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>开发状态</strong></td>
<td>维护模式</td>
<td>活跃开发</td>
</tr>
<tr>
<td><strong>新功能</strong></td>
<td>无</td>
<td>持续更新</td>
</tr>
<tr>
<td><strong>数据模型</strong></td>
<td>Tree only</td>
<td>Tree + Table</td>
</tr>
<tr>
<td><strong>查询能力</strong></td>
<td>基础 SQL</td>
<td>MATCH RECOGNIZE、窗口函数等</td>
</tr>
<tr>
<td><strong>社区支持</strong></td>
<td>逐渐减少</td>
<td>全力投入</td>
</tr>
<tr>
<td><strong>建议</strong></td>
<td>临时过渡</td>
<td><strong>长期选择</strong></td>
</tr>
</tbody>
</table>
<h3>1.3.x 用户面临的现实问题</h3>
<pre><code>问题一：功能停滞
├─ 没有 Table 模型（关系型查询）
├─ 没有 MATCH RECOGNIZE（流式分析）
├─ 没有最新的 UDF 和函数库
└─ 无法享受社区新功能

问题二：生态脱节
├─ 新工具优先支持 2.x
├─ 新文档以 2.x 为主
└─ 社区问题解答偏向 2.x

问题三：长期风险
├─ 1.3.x 最终会停止维护
├─ 迟早要迁移，越晚成本越高
└─ 团队技术栈落后
</code></pre>
<hr />
<h2>迁移评估：你的情况适合哪种方案？</h2>
<h3>方案一：直接迁移（推荐 80% 用户）</h3>
<p><strong>适合场景：</strong></p>
<pre><code>□ 1.3.x 生产环境，但可以安排维护窗口
□ 查询逻辑以标准 SQL 为主
□ 团队有测试和验证能力
□ 希望尽快获得 2.x 新功能
</code></pre>
<p><strong>迁移难度：</strong> 中等</p>
<p><strong>预计时间：</strong> 2-4 周（含测试）</p>
<hr />
<h3>方案二：渐进迁移（保守选择）</h3>
<p><strong>适合场景：</strong></p>
<pre><code>□ 超大规模集群（100+ 节点）
□ 业务不能有任何中断
□ 有充足的测试资源
□ 可以接受较长的迁移周期
</code></pre>
<p><strong>迁移难度：</strong> 较低</p>
<p><strong>预计时间：</strong> 1-3 个月</p>
<hr />
<h3>方案三：并行部署（特殊场景）</h3>
<p><strong>适合场景：</strong></p>
<pre><code>□ 新旧业务隔离
□ 需要 A/B 测试
□ 迁移风险极高
□ 有充足的硬件资源
</code></pre>
<p><strong>迁移难度：</strong> 较高</p>
<p><strong>预计时间：</strong> 1-2 个月</p>
<hr />
<h2>迁移前评估清单</h2>
<h3>1. 数据模型兼容性检查</h3>
<p><strong>Tree 模型（100% 兼容）：</strong></p>
<pre><code>-- 1.3.x 的查询在 2.x 完全兼容
SELECT * FROM root.sg.d1;
SELECT count(*) FROM root.** WHERE time &gt; now() - 1h;
</code></pre>
<p><strong>需要检查的场景：</strong></p>
<pre><code>-- 1.3.x 特有功能（2.x 已移除）
SELECT JEXL('value * 2') FROM root.sg.d1;  -- JEXL 已移除，需改为内置算术或 UDF
</code></pre>
<p><strong>检查命令：</strong></p>
<pre><code># 扫描查询日志中的 JEXL 使用
grep -i "JEXL" /path/to/query/logs/*.log

# 统计使用频率
grep -c "JEXL" /path/to/query/logs/*.log | awk -F: '{sum+=$2} END {print sum}'
</code></pre>
<hr />
<h3>2. 配置注意事项</h3>
<p>迁移到 2.x 时，配置文件格式基本兼容，但需要注意以下几点：</p>
<ul>
<li><strong><code>dn_rpc_address</code> 和 <code>dn_internal_address</code></strong>：集群部署时必须显式配置为本机实际 IP，不能使用默认值 <code>127.0.0.1</code></li>
<li>部分新增配置项需要手动合并，建议 <code>diff</code> 对比新旧配置文件</li>
<li>详细的配置变更参见 <a href="/posts/iotdb-v207-v137-overview/">V2.0.7 与 V1.3.7 功能解析</a> 中的 RPC 地址变更章节</li>
</ul>
<hr />
<h3>3. 客户端兼容性</h3>
<p><strong>需要升级的客户端：</strong></p>
<table>
<thead>
<tr>
<th>客户端</th>
<th>1.3.x 版本</th>
<th>2.x 版本</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>JDBC</td>
<td>1.3.x</td>
<td>2.0.x</td>
<td>升级依赖</td>
</tr>
<tr>
<td>Session (Java)</td>
<td>1.3.x</td>
<td>2.0.x</td>
<td>升级依赖</td>
</tr>
<tr>
<td>Python SDK</td>
<td>1.3.x</td>
<td>2.0.x</td>
<td>升级依赖</td>
</tr>
<tr>
<td>Go SDK</td>
<td>1.3.x</td>
<td>2.0.x</td>
<td>升级依赖</td>
</tr>
<tr>
<td>CLI</td>
<td>内置</td>
<td>内置</td>
<td>使用对应版本</td>
</tr>
</tbody>
</table>
<p><strong>依赖升级示例：</strong></p>
<pre><code>
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.iotdb&lt;/groupId&gt;
    &lt;artifactId&gt;iotdb-session&lt;/artifactId&gt;
    
    &lt;version&gt;1.3.7&lt;/version&gt;
    
    &lt;version&gt;2.0.7&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
<pre><code># Python
# 1.3.x 版本
pip install apache-iotdb==1.3.7

# 升级到 2.x
pip install apache-iotdb==2.0.7
</code></pre>
<hr />
<h2>方案一：直接迁移实战（推荐）</h2>
<h3>迁移架构</h3>
<pre><code>┌─────────────────────────────────────────────────────┐
│                  迁移前 (1.3.x)                      │
│                                                      │
│  应用层 → JDBC/Session → IoTDB 1.3.x 集群            │
│                                                      │
└─────────────────────────────────────────────────────┘
                      ↓ 迁移
┌─────────────────────────────────────────────────────┐
│                  迁移后 (2.x)                        │
│                                                      │
│  应用层 → JDBC/Session → IoTDB 2.x 集群              │
│              ↑                                        │
│          升级客户端依赖                               │
└─────────────────────────────────────────────────────┘
</code></pre>
<h3>步骤一：准备阶段（Week 1）</h3>
<pre><code># 1. 搭建测试环境（与生产配置一致）
$ cp -r /path/to/prod/config /path/to/test/config

# 2. 部署 2.0.7 测试集群
$ wget https://dlcdn.apache.org/iotdb/2.0.7/apache-iotdb-2.0.7-bin.tar.gz
$ tar -xzf apache-iotdb-2.0.7-bin.tar.gz
$ cd apache-iotdb-2.0.7

# 3. 修改配置（关键！）
$ vim conf/iotdb-conf.properties
dn_rpc_address=192.168.1.10      # 实际 IP
dn_internal_address=192.168.1.10

# 4. 启动测试集群
$ ./sbin/start-confignode.sh
$ ./sbin/start-datanode.sh
</code></pre>
<h3>步骤二：数据迁移（Week 2）</h3>
<h4>方式一：Cross-Cluster Sync（推荐）</h4>
<pre><code>-- 在 2.x 集群上创建 Pipe
CREATE PIPE pipe_from_13x
WITH EXTRACTOR (
    'extractor' = 'iotdb-extractor',
    'ip' = '192.168.1.10',  -- 1.3.x 集群 IP
    'port' = '6667',
    'user' = 'root',
    'password' = 'xxx'
)
WITH PROCESSOR (
    'processor' = 'do-nothing-processor'
)
WITH SINK (
    'sink' = 'iotdb-sink',
    'ip' = '192.168.1.20',  -- 2.x 集群 IP
    'port' = '6667',
    'user' = 'root',
    'password' = 'xxx'
);

-- 启动 Pipe
START PIPE pipe_from_13x;
</code></pre>
<h4>方式二：TsFile 拷贝导入</h4>
<pre><code># 1. 停止 1.3.x 集群
$ ./sbin/stop-datanode.sh

# 2. 拷贝数据目录中的 TsFile 文件
$ cp -r /path/to/iotdb-1.3.x/data/datanode/data /tmp/tsfile_backup

# 3. 在 2.x 集群上使用 LOAD 命令导入
$ ./sbin/start-cli.sh -h 192.168.1.20
IoTDB&gt; LOAD '/tmp/tsfile_backup';
</code></pre>
<h4>方式三：原地升级（适合单机或小集群）</h4>
<p>原地升级是最简单的方式，直接在现有节点上替换二进制文件：</p>
<pre><code># 1. 停止服务
$ ./sbin/stop-datanode.sh
$ ./sbin/stop-confignode.sh

# 2. 全量备份（关键！不可跳过）
$ cp -r data/ /backup/data.$(date +%Y%m%d)
$ cp -r conf/ /backup/conf.$(date +%Y%m%d)

# 3. 下载 2.x 版本
$ wget https://dlcdn.apache.org/iotdb/2.0.7/apache-iotdb-2.0.7-bin.tar.gz
$ tar -xzf apache-iotdb-2.0.7-bin.tar.gz

# 4. 替换 lib 和 sbin 目录
$ cp -r apache-iotdb-2.0.7/lib/* /path/to/iotdb/lib/
$ cp -r apache-iotdb-2.0.7/sbin/* /path/to/iotdb/sbin/

# 5. 合并配置文件（注意：不要直接覆盖 conf，需手动合并）
$ diff conf/iotdb-conf.properties apache-iotdb-2.0.7/conf/iotdb-conf.properties
# 将新增的配置项合并到现有配置中
# 特别注意修改 dn_rpc_address 和 dn_internal_address

# 6. 启动服务
$ ./sbin/start-confignode.sh
$ ./sbin/start-datanode.sh

# 7. 验证
$ ./sbin/start-cli.sh -h &lt;实际IP&gt;
IoTDB&gt; show datanodes;
IoTDB&gt; SELECT count(*) FROM root.**;
</code></pre>
<h3>步骤三：应用迁移（Week 2-3）</h3>
<pre><code># 1. 升级客户端依赖
# Java (Maven)
$ mvn versions:use-dep-version -Dincludes=org.apache.iotdb -DdepVersion=2.0.7

# Python
$ pip install --upgrade apache-iotdb==2.0.7

# 2. 修改连接配置（如果 IP 变化）
# 旧配置
jdbc:iotdb://192.168.1.10:6667
# 新配置
jdbc:iotdb://192.168.1.20:6667

# 3. 运行测试用例
$ mvn test
$ pytest tests/
</code></pre>
<h3>步骤四：验证与切换（Week 3-4）</h3>
<pre><code># 1. 数据一致性验证
$ ./sbin/start-cli.sh -h 192.168.1.10  # 1.3.x
IoTDB&gt; SELECT count(*) FROM root.**;

$ ./sbin/start-cli.sh -h 192.168.1.20  # 2.x
IoTDB&gt; SELECT count(*) FROM root.**;

# 2. 灰度切换（推荐）
# 先切换 10% 流量
# 观察 1-2 天
# 逐步增加到 50% → 100%

# 3. 回滚方案（如有问题）
# 保持 1.3.x 集群运行
# 切换流量回 1.3.x
# 排查问题后重新尝试
</code></pre>
<hr />
<h2>方案二：渐进迁移（大规模集群）</h2>
<h3>架构</h3>
<pre><code>┌─────────────────────────────────────────────────────┐
│              渐进迁移（按节点分组）                   │
│                                                      │
│  应用层                                              │
│    │                                                 │
│    ├─→ 路由层（负载均衡）                            │
│    │     ├─→ 10% 流量 → 2.x 集群（新节点）           │
│    │     └─→ 90% 流量 → 1.3.x 集群（老节点）         │
│    │                                                 │
│    │              ↓ 逐步切换                         │
│    │                                                 │
│    │     ├─→ 50% 流量 → 2.x 集群                     │
│    │     └─→ 50% 流量 → 1.3.x 集群                   │
│    │                                                 │
│    │              ↓ 完全切换                         │
│    │                                                 │
│    └─→ 100% 流量 → 2.x 集群                          │
│                                                      │
└─────────────────────────────────────────────────────┘
</code></pre>
<h3>步骤详解</h3>
<pre><code>Phase 1: 部署 2.x 集群（10% 容量）
         处理 10% 的读写流量

Phase 2: 数据同步
         使用 Pipe 从 1.3.x 同步到 2.x

Phase 3: 灰度切换
         10% → 30% → 50% → 70% → 100%
         每个阶段观察 2-3 天

Phase 4: 下线 1.3.x
         确认稳定后，下线老集群
</code></pre>
<hr />
<h2>常见坑与解决方案</h2>
<h3>坑一：RPC 地址配置错误</h3>
<p><strong>现象：</strong></p>
<pre><code>Error: Connection refused
无法连接到 2.x 集群
</code></pre>
<p><strong>原因：</strong></p>
<pre><code># 使用了默认配置
dn_rpc_address=127.0.0.1  # 只监听本地
</code></pre>
<p><strong>解决：</strong></p>
<pre><code># 修改为实际 IP
dn_rpc_address=192.168.1.20
</code></pre>
<hr />
<h3>坑二：客户端版本不兼容</h3>
<p><strong>现象：</strong></p>
<pre><code>// Java 客户端报错
Exception: Protocol version mismatch
// 1.3.x 客户端无法连接 2.x 服务端
</code></pre>
<p><strong>解决：</strong></p>
<pre><code>
&lt;version&gt;2.0.7&lt;/version&gt;
</code></pre>
<hr />
<h3>坑三：JEXL 函数报错</h3>
<p><strong>现象：</strong></p>
<pre><code>-- 查询报错
SELECT JEXL('value * 2') FROM root.sg.d1;
-- Error: Function JEXL not found
</code></pre>
<p><strong>解决：</strong></p>
<pre><code>-- 改为内置函数
SELECT value * 2 FROM root.sg.d1;

-- 或自定义 UDF
SELECT my_udf(value) FROM root.sg.d1;
</code></pre>
<hr />
<h3>坑四：内存配置不合理</h3>
<p><strong>现象：</strong></p>
<pre><code>Error: Out of memory
频繁 Full GC
</code></pre>
<p><strong>解决：</strong></p>
<pre><code># 2.x 使用动态内存管理
# 建议配置：
dn_memory_allocate_proportion=0.6
dn_heap_size=4g
</code></pre>
<hr />
<h2>迁移检查清单</h2>
<h3>迁移前</h3>
<pre><code>□ 完成兼容性评估
□ 搭建测试环境
□ 准备回滚方案
□ 通知相关团队
□ 安排维护窗口
</code></pre>
<h3>迁移中</h3>
<pre><code>□ 数据同步完成
□ 应用依赖升级
□ 查询测试通过
□ 性能测试通过
□ 监控告警配置
</code></pre>
<h3>迁移后</h3>
<pre><code>□ 数据一致性验证
□ 业务功能验证
□ 性能指标达标
□ 观察 1-2 周
□ 下线老集群
</code></pre>
<hr />
<h2>参考资料</h2>
<ul>
<li><a href="https://iotdb.apache.org/zh/UserGuide/latest/QuickStart/QuickStart_apache.html">IoTDB 2.x 文档</a></li>
<li><a href="https://iotdb.apache.org/zh/UserGuide/V1.3.x/QuickStart/QuickStart_apache.html">IoTDB 1.3.x 文档</a></li>
<li><a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">IoTDB V2.0.7 Release Notes</a></li>
<li><a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">IoTDB 公众号发布说明</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB V1.3.7 版本解析：稳定性加固与配置变更]]></title>
            <link>https://critas.wang/posts/iotdb-v137-lts-analysis/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-v137-lts-analysis/</guid>
            <pubDate>Thu, 05 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB V1.3.7 版本核心变更分析，包括安全加固措施、配置变更注意事项，以及 1.3.x 与 2.x 的版本选择建议。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>Apache IoTDB V1.3.7 与 V2.0.7 于 2026-03-04 同一天发布，但这两个版本的定位和目标用户完全不同：</p>
<ul>
<li><strong>V2.0.7</strong>：推荐版本，支持 Table 模型、MATCH RECOGNIZE 等新功能</li>
<li><strong>V1.3.7</strong>：面向现有 1.3.x 用户，不需要表模型、不希望引入更多变化的场景</li>
</ul>
<p>目前社区的开发重心已转向 2.x 系列，1.3.x 主要接收 bug 修复和安全补丁。对于仍在使用 1.3.x 的用户，这篇文章回答几个关键问题：</p>
<ol>
<li>1.3.7 修复了什么？为什么必须升级？</li>
<li>1.3.x 和 2.x 的功能差距有多大？</li>
<li>是升级 1.3.7 还是直接迁移 2.x？</li>
<li>生产环境如何零停机升级？</li>
</ol>
<blockquote>
<p>本文内容参考了 <a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">Apache IoTDB 公众号发布说明</a> 及 <a href="https://github.com/apache/iotdb/releases/tag/v1.3.7">GitHub Release Notes</a>。</p>
</blockquote>
<hr />
<h2>1.3.x 系列的定位</h2>
<h3>版本定位</h3>
<pre><code>IoTDB 版本路线图

1.3.0 ──→ 1.3.4 ──→ 1.3.5 ──→ 1.3.6 ──→ 1.3.7
  │         │          │          │          │
  │         │          │          │          └── 安全加固 + RPC 变更
  │         │          │          │
  │         │          │          └─────── CVE 修复 + 性能优化
  │         │          │
  │         │          └────────────── 功能增强
  │         │
  │         └──────────────────────── 早期生产版
  │
  └───────────────────────────────── 首个稳定版


2.0.0 ──→ 2.0.5 ──→ 2.0.6 ──→ 2.0.7
  │         │          │          │
  │         │          │          └── 安全加固 + RPC 变更
  │         │          │
  │         │          └────────────── MATCH RECOGNIZE + CVE 修复
  │         │
  │         └──────────────────────── 窗口函数 + JOIN 增强
  │
  └───────────────────────────────── Tree-Table 双模型
</code></pre>
<p><strong>1.3.x 的特点：</strong></p>
<ul>
<li>纯 Tree 模型（无 Table 模型）</li>
<li>经过长期生产验证</li>
<li>API 和配置稳定</li>
<li>社区支持周期长</li>
</ul>
<p><strong>适合场景：</strong></p>
<ul>
<li>工业 IoT 数据采集（稳定优先）</li>
<li>已有大量 Tree 模型查询逻辑</li>
<li>运维团队技术栈保守</li>
<li>无法承担升级风险的生产环境</li>
</ul>
<hr />
<h2>V1.3.7 核心变更分析</h2>
<h3>变更概览</h3>
<table>
<thead>
<tr>
<th>类别</th>
<th>变更内容</th>
<th>影响等级</th>
</tr>
</thead>
<tbody>
<tr>
<td>安全加固</td>
<td>移除高风险 RPC 接口</td>
<td><strong>高</strong></td>
</tr>
<tr>
<td>配置变更</td>
<td>RPC 默认地址改为 127.0.0.1</td>
<td><strong>高（集群部署必须注意）</strong></td>
</tr>
<tr>
<td>功能移除</td>
<td>移除 JEXL 函数</td>
<td>中</td>
</tr>
<tr>
<td>服务绑定</td>
<td>内部服务绑定到 <code>dn_internal_address</code></td>
<td>中</td>
</tr>
<tr>
<td>Pipe</td>
<td>创建 Pipe 时增加命名检查</td>
<td>低</td>
</tr>
<tr>
<td>Bug 修复</td>
<td>分区表 TTL 删除逻辑</td>
<td>中</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>注意</strong>：CVE-2025-12183、CVE-2025-66566、CVE-2025-11226 已在 <strong>v1.3.6</strong> 中修复。如果你还在使用 v1.3.5 或更早版本，升级到 v1.3.7 可以同时获得 CVE 修复和本次安全加固。</p>
</blockquote>
<hr />
<h2>重点一：RPC 默认地址变更（升级必坑）</h2>
<h3>变更内容</h3>
<pre><code># 1.3.6 及之前
dn_rpc_address=0.0.0.0

# 1.3.7
dn_rpc_address=127.0.0.1  # 默认只监听本地
</code></pre>
<h3>对 1.3.x 用户的影响</h3>
<h4>场景一：单机部署（无影响）</h4>
<pre><code># 本地 CLI 连接
./sbin/start-cli.sh
# 连接 127.0.0.1:6667，没问题
</code></pre>
<h4>场景二：集群部署（必须修改配置）</h4>
<p><strong>错误示范（升级后无法连接）：</strong></p>
<pre><code># 用户直接替换二进制文件，未修改配置
$ ./sbin/stop-datanode.sh
$ # 替换为 1.3.7
$ ./sbin/start-datanode.sh

# 然后从其他机器连接
$ ./sbin/start-cli.sh -h 192.168.1.10
# Error: Connection refused!

# 原因：1.3.7 默认监听 127.0.0.1，不接受外部连接
</code></pre>
<p><strong>正确升级流程：</strong></p>
<pre><code># 1. 升级前修改配置
$ vim conf/iotdb-conf.properties

# 修改为：
dn_rpc_address=192.168.1.10      # 本机实际 IP
dn_internal_address=192.168.1.10

# 2. 停止服务
$ ./sbin/stop-datanode.sh

# 3. 替换二进制
$ wget https://dlcdn.apache.org/iotdb/1.3.7/apache-iotdb-1.3.7-bin.tar.gz
$ tar -xzf apache-iotdb-1.3.7-bin.tar.gz

# 4. 启动服务
$ ./sbin/start-datanode.sh

# 5. 验证
$ ./sbin/start-cli.sh -h 192.168.1.10
# 连接成功！
</code></pre>
<h4>场景三：Docker 部署（需更新配置）</h4>
<pre><code># docker-compose.yml
services:
  iotdb:
    image: apache/iotdb:1.3.7
    ports:
      - "6667:6667"
    environment:
      - IOTDB_DN_RPC_ADDRESS=0.0.0.0  # 容器内需要监听所有接口
      - IOTDB_DN_INTERNAL_ADDRESS=iotdb
</code></pre>
<hr />
<h2>重点二：移除 JEXL 函数</h2>
<h3>影响评估</h3>
<p>JEXL 在实际使用中并不常见。主要原因：</p>
<ol>
<li>大多数查询用内置函数就够了</li>
<li>复杂计算通常在客户端处理</li>
<li>JEXL 性能不如编译型 UDF</li>
</ol>
<h3>替代方案</h3>
<table>
<thead>
<tr>
<th>原 JEXL 用法</th>
<th>1.3.7 替代方案</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>JEXL('value * 2')</code></td>
<td>内置算术：<code>value * 2</code></td>
</tr>
<tr>
<td><code>JEXL('sin(value)')</code></td>
<td>内置函数：<code>sin(value)</code></td>
</tr>
<tr>
<td>复杂业务逻辑</td>
<td>自定义 UDF（Java 编译）</td>
</tr>
<tr>
<td>数据转换</td>
<td>客户端预处理</td>
</tr>
</tbody>
</table>
<h3>升级前检查</h3>
<pre><code># 扫描查询日志中的 JEXL 使用
grep -i "JEXL" /path/to/query/logs/*.log

# 统计使用频率
grep -c "JEXL" /path/to/query/logs/*.log | awk -F: '{sum+=$2} END {print sum}'
</code></pre>
<hr />
<h2>1.3.7 vs 2.0.7 功能对比</h2>
<table>
<thead>
<tr>
<th>特性</th>
<th>1.3.7</th>
<th>2.0.7</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>数据模型</strong></td>
<td>Tree only</td>
<td>Tree + Table</td>
</tr>
<tr>
<td><strong>查询语言</strong></td>
<td>SQL (Tree)</td>
<td>SQL (双模型)</td>
</tr>
<tr>
<td><strong>MATCH RECOGNIZE</strong></td>
<td>不支持</td>
<td>支持</td>
</tr>
<tr>
<td><strong>Table 模型聚合</strong></td>
<td>不支持</td>
<td>支持</td>
</tr>
<tr>
<td><strong>窗口函数</strong></td>
<td>基础</td>
<td>增强（v2.0.5 新增）</td>
</tr>
<tr>
<td><strong>UDF</strong></td>
<td>基础</td>
<td>增强（UDTF，v2.0.4 新增）</td>
</tr>
<tr>
<td><strong>安全加固</strong></td>
<td>本次更新</td>
<td>本次更新</td>
</tr>
<tr>
<td><strong>生产验证</strong></td>
<td>充分</td>
<td>较充分</td>
</tr>
<tr>
<td><strong>社区支持周期</strong></td>
<td>长</td>
<td>中</td>
</tr>
</tbody>
</table>
<hr />
<h2>决策指南：升级 1.3.7 还是迁移 2.x？</h2>
<h3>1.3.x 已进入维护模式</h3>
<p><strong>这是关键信息：</strong></p>
<ul>
<li>1.3.x <strong>不再有新功能</strong>（Table 模型、MATCH RECOGNIZE 等都没有）</li>
<li>仅有安全修复和关键 bug 修复</li>
<li>社区开发重心已转向 2.x</li>
</ul>
<h3>选择 1.3.7 的场景（仅限特殊情况）</h3>
<pre><code>你的情况：
□ 生产环境已稳定运行 1.3.x 多年
□ 大量查询逻辑深度绑定 Tree 模型
□ 短期内（1-2 年）无法进行任何变更
□ 仅需安全修复，不需要新功能

→ 建议：升级到 1.3.7（临时方案），但应规划 2.x 迁移
</code></pre>
<h3>选择 2.x 的场景（推荐）</h3>
<pre><code>你的情况：
□ 新建项目（100% 推荐）
□ 现有 1.3.x 项目，可安排升级计划
□ 需要 Table 模型（关系型查询）
□ 需要 MATCH RECOGNIZE（流式分析）
□ 希望获得持续的功能更新和社区支持

→ 建议：直接部署 2.0.7 或规划迁移到 2.x
</code></pre>
<h3>迁移路径建议</h3>
<table>
<thead>
<tr>
<th>场景</th>
<th>推荐</th>
<th>理由</th>
</tr>
</thead>
<tbody>
<tr>
<td>新项目</td>
<td><strong>2.0.7</strong></td>
<td>1.3.x 已停止新功能</td>
</tr>
<tr>
<td>1.3.x 生产环境</td>
<td><strong>规划迁移 2.x</strong></td>
<td>1.3.x 进入维护模式，迟早要迁移</td>
</tr>
<tr>
<td>无法立即迁移</td>
<td><strong>1.3.7 临时过渡</strong></td>
<td>仅用于安全修复，同时规划迁移</td>
</tr>
<tr>
<td>测试/开发环境</td>
<td><strong>2.0.7</strong></td>
<td>直接使用最新版本</td>
</tr>
</tbody>
</table>
<blockquote>
<p><strong>核心观点：1.3.7 是"临时止痛药"，2.x 才是"长期解决方案"。</strong> 除非有无法克服的限制，否则应该选择 2.x。详细的迁移步骤请参考 <a href="/posts/iotdb-migration-13-to-2x/">Apache IoTDB 从 1.3.x 迁移到 2.x 完整指南</a>。</p>
</blockquote>
<hr />
<h2>生产环境升级实战（1.3.6 → 1.3.7）</h2>
<h3>升级前检查清单</h3>
<pre><code># 1. 检查当前版本
$ ./sbin/start-cli.sh -v

# 2. 检查集群状态
IoTDB&gt; show datanodes;

# 3. 检查配置
$ grep -E "rpc_address|internal_address" conf/iotdb-conf.properties

# 4. 检查 JEXL 使用情况
$ grep -r "JEXL" /path/to/queries/

# 5. 备份
$ cp -r data/ data.backup.$(date +%Y%m%d_%H%M%S)
$ cp -r conf/ conf.backup.$(date +%Y%m%d_%H%M%S)
</code></pre>
<h3>滚动升级步骤（零停机）</h3>
<pre><code># ========== 节点 A (192.168.1.10) ==========

# 1. 修改配置（在升级前！）
$ vim conf/iotdb-conf.properties
dn_rpc_address=192.168.1.10
dn_internal_address=192.168.1.10

# 2. 停止 DataNode
$ ./sbin/stop-datanode.sh

# 3. 备份
$ cp -r data/ /backup/data.nodeA.$(date +%Y%m%d)

# 4. 替换二进制
$ wget https://dlcdn.apache.org/iotdb/1.3.7/apache-iotdb-1.3.7-bin.tar.gz
$ tar -xzf apache-iotdb-1.3.7-bin.tar.gz
$ cp -r apache-iotdb-1.3.7/* /path/to/iotdb/

# 5. 启动
$ ./sbin/start-datanode.sh

# 6. 验证
$ ./sbin/start-cli.sh -h 192.168.1.10
IoTDB&gt; show datanodes;  # 确认节点状态

# ========== 节点 B (192.168.1.11) ==========
# 重复上述步骤（一次升级一个节点）
</code></pre>
<h3>升级后验证</h3>
<pre><code># 1. 版本检查
$ ./sbin/start-cli.sh -v

# 2. 基本查询测试
IoTDB&gt; SELECT count(*) FROM root.**;

# 3. 写入测试
IoTDB&gt; INSERT INTO root.sg.d1(time, s1) VALUES (now(), 123);

# 4. 日志检查
$ tail -100 log/iotdb.log | grep -E "ERROR|WARN"
# 应无异常
</code></pre>
<hr />
<h2>参考资料</h2>
<ul>
<li><a href="https://github.com/apache/iotdb/releases/tag/v1.3.7">IoTDB V1.3.7 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">IoTDB V2.0.7 Release Notes</a></li>
<li><a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">IoTDB 公众号发布说明</a></li>
<li><a href="https://iotdb.apache.org/UserGuide/V1.3.x/">IoTDB 1.x 文档</a></li>
<li><a href="https://iotdb.apache.org/UserGuide/V2.0.x/">IoTDB 2.x 文档</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[Apache IoTDB V2.0.7 版本解析：安全加固与架构优化]]></title>
            <link>https://critas.wang/posts/iotdb-v207-release-notes/</link>
            <guid isPermaLink="false">https://critas.wang/posts/iotdb-v207-release-notes/</guid>
            <pubDate>Thu, 05 Mar 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Apache IoTDB V2.0.7 版本深度分析，包括 RPC 地址变更、JEXL 函数移除、内部服务绑定优化等架构决策解读。]]></description>
            <content:encoded><![CDATA[<h2>写在前面</h2>
<p>Apache IoTDB V2.0.7/V1.3.7 于 2026-03-04 同步发布。表面上看，这是一个以安全加固为主的版本，但深入分析代码变更后，会发现这次更新背后有几个值得深思的架构决策。</p>
<p>本文不会简单罗列 Release Notes，而是从以下几个维度进行深度解析：</p>
<ol>
<li><strong>RPC 地址变更</strong> — 为什么从 <code>0.0.0.0</code> 改为 <code>127.0.0.1</code>？</li>
<li><strong>移除 JEXL 函数</strong> — 技术债的清理策略</li>
<li><strong>内部服务绑定优化</strong> — 网络分层设计</li>
<li><strong>集群部署影响</strong> — 生产环境如何平滑升级？</li>
</ol>
<blockquote>
<p>本文内容参考了 <a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">Apache IoTDB 公众号发布说明</a> 及 <a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">GitHub Release Notes</a>。</p>
</blockquote>
<hr />
<h2>变更一：RPC 默认地址变更的深度分析</h2>
<h3>变更内容</h3>
<pre><code>// V2.0.6 及之前
private String rpcAddress = "0.0.0.0";  // 监听所有网络接口

// V2.0.7
private String rpcAddress = "127.0.0.1";  // 仅监听本地回环
</code></pre>
<h3>为什么要改？</h3>
<p>这是一个典型的 <strong>安全默认值（Secure by Default）</strong> 设计决策。</p>
<p><strong>问题根源：</strong>
在云原生和容器化部署场景中，很多用户直接使用默认配置启动 IoTDB。当 <code>rpcAddress=0.0.0.0</code> 时，数据库会监听所有网络接口，包括：</p>
<ul>
<li>内网接口（eth0）</li>
<li>公网接口（如果有的话）</li>
<li>Docker 网桥接口（docker0）</li>
</ul>
<p><strong>风险场景：</strong></p>
<pre><code>┌─────────────────────────────────────────┐
│          公网/互联网                     │
│              ↓ (未授权访问)              │
│    ┌─────────────────────────┐          │
│    │   服务器 (0.0.0.0:6667)  │          │
│    │   ┌─────────────────┐   │          │
│    │   │   IoTDB         │   │          │
│    │   │   RPC: 0.0.0.0  │   │          │  ← 问题：暴露在所有接口
│    │   └─────────────────┘   │          │
│    └─────────────────────────┘          │
└─────────────────────────────────────────┘
</code></pre>
<p><strong>改为 127.0.0.1 后的效果：</strong></p>
<pre><code>┌─────────────────────────────────────────┐
│          公网/互联网                     │
│              X (无法访问)               │
│    ┌─────────────────────────┐          │
│    │   服务器 (127.0.0.1)    │          │
│    │   ┌─────────────────┐   │          │
│    │   │   IoTDB         │   │          │
│    │   │   RPC: 127.0.0.1│   │          │  ← 安全：仅本地可访问
│    │   └─────────────────┘   │          │
│    └─────────────────────────┘          │
│         ↑                               │
│    需要显式配置才能开放                  │
└─────────────────────────────────────────┘
</code></pre>
<h3>对集群部署的影响</h3>
<p><strong>这是本次升级最大的坑！</strong></p>
<h4>场景一：单机部署（无影响）</h4>
<pre><code># 默认配置即可
dn_rpc_address=127.0.0.1  # CLI 本地连接，没问题
</code></pre>
<h4>场景二：集群部署（必须修改配置）</h4>
<p><strong>错误配置（无法连接）：</strong></p>
<pre><code># DataNode A (192.168.1.10)
dn_rpc_address=127.0.0.1  # [错误] 只监听本地，其他节点无法连接！

# DataNode B (192.168.1.11)
dn_rpc_address=127.0.0.1  # [错误] 同上
</code></pre>
<p><strong>正确配置：</strong></p>
<pre><code># DataNode A (192.168.1.10)
dn_rpc_address=192.168.1.10      # 绑定实际 IP
dn_internal_address=192.168.1.10 # 内部通信地址

# DataNode B (192.168.1.11)
dn_rpc_address=192.168.1.11      # 绑定实际 IP
dn_internal_address=192.168.1.11 # 内部通信地址
</code></pre>
<h3>架构思考</h3>
<p>这个变更反映了 IoTDB 团队对安全边界的重新思考：</p>
<ol>
<li><strong>默认安全</strong>：用户需要显式选择开放网络访问，而不是反过来</li>
<li><strong>职责分离</strong>：<code>rpc_address</code> 用于客户端连接，<code>internal_address</code> 用于内部服务通信</li>
<li><strong>最小权限原则</strong>：只开放必要的网络接口</li>
</ol>
<hr />
<h2>变更二：移除 JEXL 函数 — 技术债的清理</h2>
<h3>什么是 JEXL？</h3>
<p>JEXL (Java Expression Language) 是一个轻量级的表达式解析引擎。在 IoTDB 中，它曾被用于：</p>
<ul>
<li>UDF（用户定义函数）表达式解析</li>
<li>查询条件动态计算</li>
<li>数据转换脚本</li>
</ul>
<h3>为什么要移除？</h3>
<h4>问题一：安全风险</h4>
<p>JEXL 支持动态执行任意 Java 表达式，这带来了代码注入风险：</p>
<pre><code>// 恶意用户可能构造这样的查询
SELECT JEXL("Runtime.getRuntime().exec('rm -rf /')") FROM root.sg.d1;
</code></pre>
<p>虽然 IoTDB 有权限控制，但表达式解析层的安全审计非常困难。</p>
<h4>问题二：维护成本高</h4>
<p>JEXL 是一个独立的依赖，需要：</p>
<ul>
<li>定期升级修复 CVE</li>
<li>兼容性问题处理</li>
<li>文档和维护成本</li>
</ul>
<h4>问题三：使用率低</h4>
<p>JEXL 函数在实际使用中并不常见。大多数查询场景可以通过：</p>
<ul>
<li>内置函数（<code>sin</code>, <code>cos</code>, <code>avg</code>, <code>max</code> 等）</li>
<li>客户端预处理</li>
<li>外部计算引擎（Spark/Flink）</li>
</ul>
<p>来实现。</p>
<h3>替代方案</h3>
<table>
<thead>
<tr>
<th>原 JEXL 场景</th>
<th>替代方案</th>
</tr>
</thead>
<tbody>
<tr>
<td>简单数学计算</td>
<td>内置算术运算符 (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>)</td>
</tr>
<tr>
<td>复杂函数</td>
<td>自定义 UDF（Java 编译）</td>
</tr>
<tr>
<td>数据转换</td>
<td>客户端预处理或 ETL 工具</td>
</tr>
</tbody>
</table>
<hr />
<h2>变更三：内部服务绑定优化</h2>
<h3>变更前</h3>
<pre><code>// 所有服务绑定到同一个地址
String bindAddress = config.getRpcAddress();  // 可能是 0.0.0.0
rpcService.bind(bindAddress);
internalService.bind(bindAddress);  // 内部服务也暴露在外网！
</code></pre>
<h3>变更后</h3>
<pre><code>// RPC 和内部服务使用不同地址
String rpcAddress = config.getRpcAddress();        // 127.0.0.1
String internalAddress = config.getInternalAddress(); // 内网 IP

rpcService.bind(rpcAddress);
internalService.bind(internalAddress);  // 内部服务只监听内网
</code></pre>
<h3>架构意义</h3>
<p>这是一个网络分层的设计改进：</p>
<pre><code>┌─────────────────────────────────────┐
│           客户端层                   │
│         (CLI, JDBC, Session)        │
│              ↓ RPC (6667)           │
├─────────────────────────────────────┤
│           DataNode 层                │
│  ┌─────────────────────────────┐    │
│  │ RPC Service: 127.0.0.1      │    │  ← 仅本地可访问
│  └─────────────────────────────┘    │
│  ┌─────────────────────────────┐    │
│  │ Internal Service: 内网 IP   │    │  ← 仅集群内可访问
│  └─────────────────────────────┘    │
└─────────────────────────────────────┘
</code></pre>
<hr />
<h2>其他变更</h2>
<h3>Pipe 命名检查</h3>
<p>V2.0.7 新增了创建 Pipe 时的命名合法性校验，防止因非法字符导致的运行时错误。</p>
<h3>分区表 TTL 删除逻辑修复</h3>
<p>修复了分区表自动删除逻辑中的问题：此前仅 DB 级别配置的 TTL 生效，且使用的是 DB 内的最大 TTL 值。</p>
<h3>安全漏洞（v2.0.6 已修复）</h3>
<p>需要注意的是，以下 CVE 漏洞已在 <strong>v2.0.6/v1.3.6</strong> 中修复，而非本次 v2.0.7：</p>
<ul>
<li><strong>CVE-2025-12183</strong>（高危）— 远程代码执行</li>
<li><strong>CVE-2025-66566</strong>（中危）— 权限绕过</li>
<li><strong>CVE-2025-11226</strong>（中危）— 信息泄露</li>
</ul>
<p>如果你还在使用 v2.0.5 或更早版本，建议直接升级到 v2.0.7 以同时获得 CVE 修复和本次安全加固。</p>
<hr />
<h2>生产环境升级指南</h2>
<h3>升级前检查清单</h3>
<pre><code># 1. 检查当前配置
grep -E "rpc_address|internal_address" conf/iotdb-conf.properties

# 2. 检查集群拓扑
./sbin/start-cli.sh
&gt; show datanodes;
&gt; show confignodes;

# 3. 备份（重要！）
cp -r data/ data.backup.$(date +%Y%m%d)
cp -r conf/ conf.backup.$(date +%Y%m%d)
</code></pre>
<h3>集群升级步骤</h3>
<h4>步骤一：准备新配置</h4>
<pre><code># iotdb-conf.properties (每个节点不同)

# ============ 节点 A (192.168.1.10) ============
dn_rpc_address=192.168.1.10
dn_internal_address=192.168.1.10
dn_seed_config_node=192.168.1.10:9003

# ============ 节点 B (192.168.1.11) ============
dn_rpc_address=192.168.1.11
dn_internal_address=192.168.1.11
dn_seed_config_node=192.168.1.10:9003
</code></pre>
<h4>步骤二：滚动升级</h4>
<pre><code># 1. 升级 ConfigNode（先主后备）
./sbin/stop-confignode.sh
# 替换二进制文件
./sbin/start-confignode.sh

# 2. 滚动升级 DataNode（一次一个节点）
for node in node1 node2 node3; do
    ssh $node "./sbin/stop-datanode.sh"
    # 替换二进制文件和配置
    ssh $node "./sbin/start-datanode.sh"
    # 验证节点加入集群
    ./sbin/start-cli.sh -e "show datanodes"
done
</code></pre>
<h4>步骤三：验证</h4>
<pre><code># 1. 检查集群状态
./sbin/start-cli.sh
&gt; show datanodes;
&gt; show confignodes;

# 2. 测试跨节点查询
&gt; SELECT count(*) FROM root.sg.d1;

# 3. 检查日志
tail -f log/iotdb.log | grep -E "ERROR|WARN"
</code></pre>
<hr />
<h2>总结</h2>
<h3>这次更新反映了什么趋势？</h3>
<ol>
<li><strong>安全优先</strong>：从"方便使用"转向"默认安全"</li>
<li><strong>技术债清理</strong>：移除使用率低、风险高的功能（JEXL）</li>
<li><strong>网络分层</strong>：明确区分客户端流量和内部服务流量</li>
</ol>
<h3>对用户的建议</h3>
<table>
<thead>
<tr>
<th>用户类型</th>
<th>建议</th>
</tr>
</thead>
<tbody>
<tr>
<td>单机测试</td>
<td>直接升级，无影响</td>
</tr>
<tr>
<td>集群部署</td>
<td><strong>必须修改配置</strong>后再升级</td>
</tr>
<tr>
<td>容器化部署</td>
<td>更新 Docker 镜像和配置模板</td>
</tr>
<tr>
<td>云服务</td>
<td>联系云厂商确认配置模板</td>
</tr>
</tbody>
</table>
<hr />
<h2>参考资料</h2>
<ul>
<li><a href="https://github.com/apache/iotdb/releases/tag/v2.0.7">IoTDB V2.0.7 Release Notes</a></li>
<li><a href="https://github.com/apache/iotdb/releases/tag/v1.3.7">IoTDB V1.3.7 Release Notes</a></li>
<li><a href="https://mp.weixin.qq.com/s/X0hu_CxgS12cQXl67mYmiQ">IoTDB 公众号发布说明</a></li>
<li><a href="https://iotdb.apache.org/UserGuide/V2.0.x/Configuration/ConfigurationFile.html">IoTDB 配置文档</a></li>
</ul>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[AI 编程工具与 IDE 全景介绍与对比]]></title>
            <link>https://critas.wang/posts/ai-coding-tools-comparison/</link>
            <guid isPermaLink="false">https://critas.wang/posts/ai-coding-tools-comparison/</guid>
            <pubDate>Wed, 25 Feb 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[2025-2026 主流 AI 编程工具深度解析，涵盖终端智能体、AI 原生 IDE、IDE 插件三大类别的横向对比与选型建议。]]></description>
            <content:encoded><![CDATA[<blockquote>
<p><strong>说明</strong>：本文为个人学习笔记整理，涉及的产品信息、定价与评测结论均来自公开资料与个人使用体验，仅代表个人观点，<strong>不含商业推广、付费软文或佣金链接，也不构成任何购买建议</strong>；产品能力与价格随时可能变化，请以官方信息为准。</p>
</blockquote>
<h2>一、AI 编程工具市场概述</h2>
<p>2024-2026 年，AI 编程工具市场经历了爆发式增长。从最初的代码自动补全，到如今能够自主完成复杂多文件重构的智能体（Agent），AI 编程助手已经从「锦上添花」变成了开发者的核心生产力工具。</p>
<p>当前市场上的 AI 编程工具大致可以分为三大类别：</p>
<h3>1. AI 原生 IDE（AI-Native Editors）</h3>
<p>以 AI 为核心重新构建的编辑器，如 Cursor、Windsurf、Trae、Kiro 等。它们理解整个代码库，而非仅限于当前文件，提供深度的上下文感知能力。</p>
<h3>2. IDE 插件/扩展（IDE Extensions）</h3>
<p>嵌入现有编辑器的 AI 助手，如 GitHub Copilot、Cline、Continue、Augment Code、Sourcegraph Cody、JetBrains AI Assistant 等。采用成本低，但能力通常不如原生 IDE 深度集成。</p>
<h3>3. 终端智能体（Terminal Agents / CLI Tools）</h3>
<p>在终端中运行的自主编程代理，如 Claude Code、OpenAI Codex CLI、OpenCode、Aider 等。开发者分配任务，它们跨文件、跨工具自主执行。适合高级开发者和自动化场景。</p>
<p>据统计，GitHub Copilot 仍以约 42% 的付费市场份额领先，但 Cursor 的年收入已突破 5 亿美元。Claude Opus 4.6 在 SWE-bench Verified 上达到 80.8%，在该基准上处于前列。市场并未走向集中，而是走向专业化。</p>
<hr />
<h2>二、终端智能体类工具（Terminal Agents）</h2>
<h3>2.1 Claude Code（Anthropic）</h3>
<p><strong>产品定位：</strong> Anthropic 官方推出的终端优先（Terminal-First）AI 编程智能体，面向专业开发者。</p>
<p><strong>底层模型：</strong> Claude Opus 4.6 / Sonnet 4.6 / Haiku 4.5，支持自动模型切换。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>终端原生体验，直接在命令行中与 AI 交互，无需离开开发环境</li>
<li>深度代码库理解：自动索引整个项目，支持跨文件搜索、编辑、重构</li>
<li>自主执行能力：可运行 Shell 命令、管理文件、执行测试、操作 Git</li>
<li>支持 MCP（Model Context Protocol）协议，可连接外部工具和数据源</li>
<li>多级权限控制：Suggest / Auto Edit / Full Auto 三种审批模式</li>
<li>支持 Hooks 机制和子代理（Sub-agent）并行执行</li>
</ul>
<p><strong>适用场景：</strong> 复杂多文件重构、自动化工作流、CI/CD 集成、终端重度用户。</p>
<p><strong>价格：</strong> 按 API 用量计费。Max 订阅计划 $100-$200/月。</p>
<p><strong>优势：</strong> 推理能力在 SWE-bench Verified 上达到 80.8%，终端集成度高，自主性强。</p>
<p><strong>不足：</strong> 纯终端界面对新手不够友好，无图形化编辑器，API 费用较高。</p>
<h3>2.2 OpenAI Codex CLI（OpenAI）</h3>
<p><strong>产品定位：</strong> OpenAI 推出的终端 AI 编程代理，Claude Code 的直接竞品。</p>
<p><strong>底层模型：</strong> GPT-5.1-Codex-Max / o3 推理模型。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>终端原生运行，支持文件读写、Shell 命令执行、Git 操作</li>
<li>三级审批模式：Suggest / Auto Edit / Full Auto</li>
<li>云端 Codex Agent 版本可在 ChatGPT 中运行，支持多代理并行</li>
<li>Codex App（macOS 桌面版）支持 Git Worktree、Skills、Automations</li>
<li>支持 MCP 协议</li>
</ul>
<p><strong>适用场景：</strong> 终端开发者、OpenAI 生态用户、需要云端+本地双模式的团队。</p>
<p><strong>价格：</strong> CLI 免费开源；Codex Agent 需 ChatGPT Plus $20/月 或 Pro $200/月。</p>
<p><strong>优势：</strong> 免费开源 CLI，云端 Agent 功能强大，GPT 生态集成好。</p>
<p><strong>不足：</strong> CLI 功能相比 Claude Code 仍有差距，云端版需付费订阅。</p>
<h3>2.3 OpenCode</h3>
<p><strong>产品定位：</strong> 开源终端 AI 编程代理，主打「BYOK」（Bring Your Own Key）和模型自由。</p>
<p><strong>底层模型：</strong> 支持 75+ 模型提供商，包括 Claude、OpenAI、Gemini、本地模型（Ollama）等。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>终端原生 TUI 界面，Go + JavaScript 构建，性能优秀</li>
<li>支持多会话、LSP 自动加载、上下文感知</li>
<li>Client/Server 架构，支持桌面应用和 VS Code 扩展</li>
<li>完全开源，数据隐私可控</li>
</ul>
<p><strong>适用场景：</strong> 注重隐私、需要使用本地模型、希望灵活切换模型的开发者。</p>
<p><strong>价格：</strong> 免费开源，模型费用自付。</p>
<p><strong>优势：</strong> 模型自由度高（支持 75+ 模型提供商），完全开源，隐私友好。</p>
<p><strong>不足：</strong> 社区生态不如 Claude Code 成熟，部分高级功能仍在开发中。</p>
<h3>2.4 Aider</h3>
<p><strong>产品定位：</strong> 开源终端 AI 结对编程工具，专注于 Git 仓库内的代码编辑。</p>
<p><strong>底层模型：</strong> 支持 Claude、GPT-4o、DeepSeek、本地模型等几乎所有主流 LLM。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>Git 深度集成：自动提交、变更追踪、分支管理</li>
<li>多文件协同编辑，理解项目完整上下文</li>
<li>支持多种编辑模式（whole file / diff / unified diff）</li>
<li>丰富的命令行选项和配置</li>
</ul>
<p><strong>适用场景：</strong> Git 工作流重度用户、需要精细控制代码变更的开发者。</p>
<p><strong>价格：</strong> 免费开源，模型费用自付。</p>
<p><strong>优势：</strong> Git 集成完整（自动提交、变更追踪、分支管理），编辑模式灵活，社区活跃。</p>
<p><strong>不足：</strong> 自主执行能力不如 Claude Code，无 Shell 命令执行。</p>
<hr />
<h2>三、AI 原生 IDE（AI-Native Editors）</h2>
<h3>3.1 Cursor</h3>
<p><strong>产品定位：</strong> 用户规模较大的 AI 原生代码编辑器，基于 VS Code 深度改造，公开报道称年收入突破 5 亿美元。</p>
<p><strong>底层模型：</strong> 支持 Claude Sonnet/Opus、GPT-4o、自研模型，可自由切换。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>代码库级上下文理解（Codebase Indexing），支持 @codebase 全局搜索</li>
<li>Composer 模式：多文件同时编辑，Agent 自主执行任务</li>
<li>Tab 智能补全：基于上下文的多行预测补全</li>
<li>内联编辑（Cmd+K）：选中代码直接用自然语言修改</li>
<li>支持自定义 Rules 和 .cursorrules 项目配置</li>
</ul>
<p><strong>适用场景：</strong> 日常编码、复杂项目开发、需要深度代码库理解的团队。</p>
<p><strong>价格：</strong> Hobby 免费（有限额）；Pro $20/月；Business $40/月。</p>
<p><strong>优势：</strong> IDE 交互体验成熟（基于 VS Code 改造），代码库索引（Codebase Indexing）覆盖度高，Composer Agent 能力强。</p>
<p><strong>不足：</strong> Pro 版有请求限额，重度使用可能需要自带 API Key。</p>
<h3>3.2 Windsurf（原 Codeium）</h3>
<p><strong>产品定位：</strong> AI 原生 IDE，主打高性价比和 Agentic 工作流。2025 年被 OpenAI 宣布以约 30 亿美元收购。</p>
<p><strong>底层模型：</strong> GPT-4、Claude、自研模型，收购后将深度集成 OpenAI 模型。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>Cascade Agent：自主执行多步骤任务，支持终端命令</li>
<li>Flows 系统：AI 与开发者协作的工作流引擎</li>
<li>慷慨的免费额度，入门门槛低</li>
<li>基于 VS Code 构建，插件生态兼容</li>
</ul>
<p><strong>适用场景：</strong> 预算敏感的开发者、需要 Agentic 能力但不想付高价的团队。</p>
<p><strong>价格：</strong> 免费版额度慷慨；Pro $10/月；Team $15/月。</p>
<p><strong>优势：</strong> 订阅价格档位低（Pro $10/月），免费额度大方，Cascade Agent 体验好。</p>
<p><strong>不足：</strong> 被 OpenAI 收购后未来方向不确定，部分高级功能不如 Cursor 成熟。</p>
<h3>3.3 Trae（ByteDance / 字节跳动）</h3>
<p><strong>产品定位：</strong> 字节跳动推出的免费 AI IDE，定位「真正的 AI 工程师」，主打自主开发能力。</p>
<p><strong>底层模型：</strong> Claude Sonnet、GPT-4o、豆包大模型等。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>SOLO Agent：自主完成从需求到部署的完整开发流程</li>
<li>Builder 模式 + Chat 模式双模交互</li>
<li>Trae Agent CLI：终端版自主编程代理</li>
<li>DevBox 云端开发环境集成</li>
<li>基于 VS Code 构建，完全免费</li>
</ul>
<p><strong>适用场景：</strong> 个人开发者、初创团队、需要免费 AI IDE 的用户。</p>
<p><strong>价格：</strong> 完全免费。</p>
<p><strong>优势：</strong> 完全免费，SOLO Agent 自主能力强，支持中文。</p>
<p><strong>不足：</strong> 企业级功能不足，数据隐私存在顾虑（字节跳动背景），生态不如 Cursor。</p>
<h3>3.4 Kiro（AWS）</h3>
<p><strong>产品定位：</strong> AWS 推出的规格驱动（Spec-Driven）Agentic IDE，强调从「Vibe Coding」到生产级代码的转变。</p>
<p><strong>底层模型：</strong> Claude Sonnet 4（Claude 3.7 作为备选）。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>Spec-Driven 开发：将自然语言需求转化为规格文档、设计、任务列表，再生成代码</li>
<li>Steering 文件系统：项目级 AI 行为配置</li>
<li>Hooks 自动化：代码保存时自动触发测试、lint 等</li>
<li>深度 AWS 服务集成，支持 MCP</li>
<li>基于 VS Code (Code-OSS) 构建</li>
</ul>
<p><strong>适用场景：</strong> AWS 生态用户、企业级项目、需要结构化开发流程的团队。</p>
<p><strong>价格：</strong> 免费预览中；正式版预计有免费和付费层级。</p>
<p><strong>优势：</strong> 规格驱动方法论独特，AWS 集成深度，适合企业级开发。</p>
<p><strong>不足：</strong> 仍在预览阶段，功能不够成熟，非 AWS 用户吸引力有限。</p>
<hr />
<h2>四、IDE 插件/扩展类工具（IDE Extensions）</h2>
<h3>4.1 GitHub Copilot（Microsoft / GitHub）</h3>
<p><strong>产品定位：</strong> 全球付费市场份额领先（约 42%）的 AI 编程助手，深度集成 GitHub 生态。</p>
<p><strong>底层模型：</strong> GPT-5、GPT-4.1、Claude Sonnet、Gemini 等多模型支持。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>实时代码补全：行内智能建议，支持多行预测</li>
<li>Copilot Chat：对话式编程助手，支持 @workspace 上下文</li>
<li>Copilot Agent Mode：自主执行多步骤任务</li>
<li>GitHub 深度集成：PR 审查、Issue 分析、Actions 自动化</li>
<li>支持 VS Code、JetBrains、Neovim、Xcode 等主流 IDE</li>
</ul>
<p><strong>适用场景：</strong> GitHub 生态用户、团队协作、企业级开发。</p>
<p><strong>价格：</strong> Free 免费（有限额）；Pro $10/月；Business $19/月；Enterprise $39/月。</p>
<p><strong>优势：</strong> 付费市场份额领先（约 42%），GitHub 生态集成紧密，多 IDE 支持，企业合规认证齐全。</p>
<p><strong>不足：</strong> Agent 能力不如 Cursor/Claude Code，代码库理解深度有限。</p>
<h3>4.2 Cline</h3>
<p><strong>产品定位：</strong> 开源自主 AI 编程代理，作为 VS Code 扩展运行，模型无关。</p>
<p><strong>底层模型：</strong> 支持 Claude、GPT、Gemini、DeepSeek、本地模型等，用户自选。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>自主执行：创建/编辑文件、运行终端命令、浏览器操作</li>
<li>人机协作审批：每步操作需用户确认，安全可控</li>
<li>BYOK 模式：自带 API Key，无订阅费</li>
<li>MCP 支持：可连接外部工具和服务</li>
<li>VS Code 安装量超 500 万</li>
</ul>
<p><strong>适用场景：</strong> 需要灵活选择模型、注重成本控制的开发者。</p>
<p><strong>价格：</strong> 免费开源，模型费用自付。</p>
<p><strong>优势：</strong> 完全开源，模型自由，社区活跃，功能全面。</p>
<p><strong>不足：</strong> 每步审批可能影响效率，上下文管理不如 Cursor 精细。</p>
<h3>4.3 Augment Code</h3>
<p><strong>产品定位：</strong> 企业级 AI 编程助手，主打超大代码库上下文理解（40 万+文件）。</p>
<p><strong>底层模型：</strong> 自研 Context Engine + 多模型支持。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>Context Engine：可同时处理 40 万+文件，企业级代码库理解</li>
<li>Next Edit 预测：智能预判下一步编辑</li>
<li>MCP 和原生工具支持</li>
<li>SOC 2 Type II 和 ISO/IEC 42001 认证</li>
</ul>
<p><strong>适用场景：</strong> 大型企业、超大代码库项目。</p>
<p><strong>价格：</strong> Indie $20/月；Standard $60/月；Enterprise 定制。</p>
<p><strong>优势：</strong> 超大代码库支持上限高（官方称可同时处理 40 万+文件），企业合规认证齐全。</p>
<p><strong>不足：</strong> 价格较高，个人开发者性价比不如 Cursor。</p>
<h3>4.4 Continue</h3>
<p><strong>产品定位：</strong> 开源 AI 编程助手，支持 VS Code 和 JetBrains，主打可定制性。</p>
<p><strong>底层模型：</strong> 支持几乎所有主流模型，包括本地模型。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>Tab 自动补全 + Chat 对话 + Agent 模式三合一</li>
<li>完全开源，可自托管，数据不出本地</li>
<li>支持自定义 Slash 命令和上下文提供者</li>
</ul>
<p><strong>价格：</strong> 免费开源。</p>
<p><strong>优势：</strong> 开源可定制，隐私友好，JetBrains 支持好。</p>
<p><strong>不足：</strong> 功能深度不如商业产品，需要自行配置模型。</p>
<h3>4.5 Sourcegraph Cody</h3>
<p><strong>产品定位：</strong> 基于 Sourcegraph 代码搜索引擎的 AI 编程助手，擅长大型代码库导航。</p>
<p><strong>底层模型：</strong> Claude、GPT-4o、Gemini 等多模型支持。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>全仓库上下文理解，基于 Sourcegraph 代码图谱</li>
<li>智能代码搜索 + AI Chat + 自动补全三合一</li>
<li>自定义 Prompts 和 Commands</li>
<li>支持 VS Code 和 JetBrains</li>
</ul>
<p><strong>价格：</strong> Free 免费；Pro $9/月；Enterprise 年付定制。</p>
<p><strong>优势：</strong> 代码搜索能力突出（基于 Sourcegraph 代码图谱），大型 Monorepo 支持好。</p>
<p><strong>不足：</strong> Agent 能力较弱，主要是辅助而非自主执行。</p>
<h3>4.6 JetBrains AI Assistant</h3>
<p><strong>产品定位：</strong> JetBrains 官方 AI 助手，深度集成 IntelliJ 全家桶。</p>
<p><strong>底层模型：</strong> JetBrains 自研模型 + Claude、GPT-4o 等。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>与 IntelliJ、PyCharm、WebStorm 等 IDE 深度集成</li>
<li>AI Chat + 代码补全 + 重构建议</li>
<li>理解项目结构和框架约定</li>
</ul>
<p><strong>价格：</strong> AI Free 免费（有限额）；AI Pro 包含在 JetBrains All Products Pack 中。</p>
<p><strong>优势：</strong> JetBrains 用户无缝体验，与 IntelliJ 全家桶集成紧密。</p>
<p><strong>不足：</strong> 仅限 JetBrains IDE，Agent 能力较弱。</p>
<h3>4.7 Tabnine</h3>
<p><strong>产品定位：</strong> 隐私优先的 AI 编程助手，支持本地部署和企业私有化。</p>
<p><strong>底层模型：</strong> 自研模型，支持本地运行，不将代码发送到云端。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>本地模型运行，代码不出企业网络</li>
<li>支持 VS Code、JetBrains、Neovim 等 15+ IDE</li>
<li>团队代码风格学习和适配</li>
<li>SOC 2 Type II 认证，企业合规</li>
</ul>
<p><strong>价格：</strong> Dev $9/月；Enterprise 定制。</p>
<p><strong>优势：</strong> 支持本地部署、代码不出企业网络，企业合规。</p>
<p><strong>不足：</strong> 模型能力不如 Claude/GPT，Agent 功能缺失。</p>
<h3>4.8 Amazon Q Developer（AWS）</h3>
<p><strong>产品定位：</strong> AWS 官方 AI 开发助手，覆盖编码、测试、部署、运维全流程。</p>
<p><strong>底层模型：</strong> Amazon 自研基础模型。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>代码补全 + AI Chat + 代码转换（Java 8→17 等）</li>
<li>安全扫描与自动修复</li>
<li>AWS 服务深度集成：CloudFormation、CDK、Lambda 等</li>
<li>支持 VS Code、JetBrains、命令行</li>
</ul>
<p><strong>价格：</strong> Free 免费（有限额）；Pro $19/月。</p>
<p><strong>优势：</strong> AWS 集成最深，安全扫描能力强，免费额度可观。</p>
<p><strong>不足：</strong> 通用编码能力不如 Copilot/Cursor，非 AWS 场景吸引力有限。</p>
<hr />
<h2>五、其他值得关注的工具</h2>
<h3>5.1 Replit AI</h3>
<p><strong>产品定位：</strong> 云端 AI 开发平台，主打浏览器内全栈开发，零配置即用。</p>
<p><strong>底层模型：</strong> 自研模型 + Claude、GPT 等。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>浏览器内完整 IDE，无需本地环境</li>
<li>Replit Agent：从自然语言描述生成完整应用</li>
<li>一键部署，内置数据库和托管服务</li>
</ul>
<p><strong>价格：</strong> Free 免费；Replit Core $25/月。</p>
<p><strong>优势：</strong> 零配置，适合快速原型和教学。</p>
<p><strong>不足：</strong> 不适合大型项目，性能受限于云端。</p>
<h3>5.2 Zed AI</h3>
<p><strong>产品定位：</strong> 高性能原生代码编辑器，内置 AI 助手，主打速度和协作。</p>
<p><strong>底层模型：</strong> Claude、GPT-4o、本地模型等。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>Rust 构建，启动和响应速度快</li>
<li>内置 AI Chat 和 Inline Assist</li>
<li>实时多人协作编辑</li>
</ul>
<p><strong>价格：</strong> 免费开源。</p>
<p><strong>优势：</strong> 响应性能好，协作体验好，开源。</p>
<p><strong>不足：</strong> 插件生态不如 VS Code，AI 功能深度有限。</p>
<h3>5.3 Roo Code</h3>
<p><strong>产品定位：</strong> Cline 的「可靠性优先」分支，强调稳定性和企业适用性。</p>
<p><strong>底层模型：</strong> 支持所有主流模型，与 Cline 相同的 BYOK 模式。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>基于 Cline 代码库，增强了稳定性和错误处理</li>
<li>自定义模式系统，可定义不同角色的 AI 行为</li>
<li>更保守的默认设置，减少意外操作</li>
</ul>
<p><strong>价格：</strong> 免费开源。</p>
<p><strong>优势：</strong> 比 Cline 更稳定可靠，适合生产环境。</p>
<p><strong>不足：</strong> 社区规模不如 Cline，创新速度较慢。</p>
<h3>5.4 阿里云 Coding Plan（Alibaba Cloud Model Studio）— 模型订阅平台</h3>
<p><strong>产品定位：</strong> 阿里云百炼平台推出的多模型编程订阅服务（非编程工具本身），一个订阅即可切换多款主流编程模型，搭配 Claude Code、Cline 等客户端使用，主打多模型低价订阅。</p>
<p><strong>底层模型：</strong> Qwen3.5-Plus（397B 参数）、GLM-5（智谱 744B 参数）、MiniMax M2.5（230B 参数）、Kimi K2.5、Qwen3-Coder-Next 等。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>多模型自由切换：一个订阅覆盖 Qwen、GLM-5、MiniMax M2.5、Kimi K2.5 等多款模型</li>
<li>兼容主流 AI 编程工具：支持 Claude Code、Cline、OpenClaw、Qwen Code 等客户端接入</li>
<li>订阅价格低：入门版每月最多 18,000 次请求，首月 ¥7.9（约 $1）</li>
<li>2026 年 2 月最新更新：新增 GLM-5 和 MiniMax M2.5 模型支持</li>
<li>API 兼容：提供标准 API 接口，开发者可灵活集成到自有工作流</li>
</ul>
<p><strong>适用场景：</strong> 中国开发者、预算敏感用户、需要多模型对比选择的团队、Claude Code 用户寻求低成本替代方案。</p>
<p><strong>价格：</strong> 入门版首月 ¥7.9 后 ¥39/月（18,000 次/月）；Pro 版首月 ¥39 后 ¥199/月（90,000 次/月）。</p>
<p><strong>优势：</strong> 订阅价格显著低于海外同类服务，多模型自由切换，国内访问稳定。</p>
<p><strong>不足：</strong> 模型能力与 Claude Opus/GPT-5 仍有差距，国际用户使用不便，生态成熟度不如海外平台。</p>
<h3>5.5 Kilo Code</h3>
<p><strong>产品定位：</strong> Cline 生态的新竞争者，获得 800 万美元种子轮融资。</p>
<p><strong>底层模型：</strong> 支持多模型，BYOK 模式。</p>
<p><strong>核心特性：</strong></p>
<ul>
<li>VS Code 扩展，自主编程代理</li>
<li>强调开发者体验和易用性</li>
<li>活跃的社区和快速迭代</li>
</ul>
<p><strong>价格：</strong> 免费开源。</p>
<p><strong>优势：</strong> 有资金支持，迭代快速。</p>
<p><strong>不足：</strong> 较新，生态和功能成熟度不如 Cline。</p>
<hr />
<h2>六、综合对比表格</h2>
<p>以下表格从多个维度对主流 AI 编程工具进行横向对比：</p>
<table>
<thead>
<tr>
<th>工具名称</th>
<th>类型</th>
<th>底层模型</th>
<th>开源</th>
<th>价格</th>
<th>Agent 能力</th>
<th>IDE 支持</th>
<th>核心优势</th>
<th>主要不足</th>
</tr>
</thead>
<tbody>
<tr>
<td>Claude Code</td>
<td>终端 Agent</td>
<td>Claude Opus/Sonnet/Haiku</td>
<td>否</td>
<td>按量/$100+月</td>
<td>极强</td>
<td>终端/VS Code</td>
<td>推理能力强（SWE-bench 80.8%），自主性高</td>
<td>终端门槛高，费用高</td>
</tr>
<tr>
<td>Codex CLI</td>
<td>终端 Agent</td>
<td>GPT-5.1/o3</td>
<td>是</td>
<td>免费/$20+月</td>
<td>强</td>
<td>终端</td>
<td>免费开源，云端+本地</td>
<td>功能不如 Claude Code</td>
</tr>
<tr>
<td>OpenCode</td>
<td>终端 Agent</td>
<td>75+ 模型</td>
<td>是</td>
<td>免费</td>
<td>强</td>
<td>终端/VS Code</td>
<td>模型自由，隐私友好</td>
<td>生态不够成熟</td>
</tr>
<tr>
<td>Aider</td>
<td>终端 Agent</td>
<td>多模型</td>
<td>是</td>
<td>免费</td>
<td>中</td>
<td>终端</td>
<td>Git 集成完整</td>
<td>无 Shell 执行</td>
</tr>
<tr>
<td>Cursor</td>
<td>AI 原生 IDE</td>
<td>多模型</td>
<td>否</td>
<td>免费/$20月</td>
<td>强</td>
<td>独立 IDE</td>
<td>IDE 体验成熟</td>
<td>有请求限额</td>
</tr>
<tr>
<td>Windsurf</td>
<td>AI 原生 IDE</td>
<td>多模型</td>
<td>否</td>
<td>免费/$10月</td>
<td>强</td>
<td>独立 IDE</td>
<td>价格档位低</td>
<td>收购后方向不确定</td>
</tr>
<tr>
<td>Trae</td>
<td>AI 原生 IDE</td>
<td>多模型</td>
<td>否</td>
<td>免费</td>
<td>强</td>
<td>独立 IDE</td>
<td>完全免费</td>
<td>隐私顾虑</td>
</tr>
<tr>
<td>Kiro</td>
<td>AI 原生 IDE</td>
<td>Claude Sonnet</td>
<td>否</td>
<td>免费预览</td>
<td>中强</td>
<td>独立 IDE</td>
<td>规格驱动，AWS 集成</td>
<td>仍在预览阶段</td>
</tr>
<tr>
<td>GitHub Copilot</td>
<td>IDE 插件</td>
<td>GPT-5/多模型</td>
<td>否</td>
<td>免费/$10月</td>
<td>中强</td>
<td>多 IDE</td>
<td>市占率领先，GitHub 集成</td>
<td>Agent 能力一般</td>
</tr>
<tr>
<td>Cline</td>
<td>IDE 插件</td>
<td>多模型</td>
<td>是</td>
<td>免费</td>
<td>强</td>
<td>VS Code</td>
<td>开源灵活，功能全面</td>
<td>每步需审批</td>
</tr>
<tr>
<td>Augment Code</td>
<td>IDE 插件</td>
<td>自研+多模型</td>
<td>否</td>
<td>$20-60月</td>
<td>中</td>
<td>VS Code/JB</td>
<td>40万+文件上下文</td>
<td>价格较高</td>
</tr>
<tr>
<td>Tabnine</td>
<td>IDE 插件</td>
<td>自研</td>
<td>否</td>
<td>$9月起</td>
<td>弱</td>
<td>15+ IDE</td>
<td>可本地部署</td>
<td>模型能力有限</td>
</tr>
<tr>
<td>Amazon Q Dev</td>
<td>IDE 插件</td>
<td>Amazon 自研</td>
<td>否</td>
<td>免费/$19月</td>
<td>中</td>
<td>VS Code/JB</td>
<td>AWS 集成最深</td>
<td>通用能力一般</td>
</tr>
<tr>
<td>阿里云 Coding Plan</td>
<td>模型订阅平台</td>
<td>Qwen/GLM-5/M2.5</td>
<td>否</td>
<td>¥7.9-199月</td>
<td>依客户端</td>
<td>多客户端</td>
<td>多模型切换，价格低</td>
<td>模型能力有差距</td>
</tr>
</tbody>
</table>
<hr />
<h2>七、选型建议与总结</h2>
<h3>7.1 按开发者类型推荐</h3>
<h4>终端重度用户 / 高级开发者</h4>
<p>个人更倾向 Claude Code：在这类工具中推理能力与自主性表现突出。预算有限可选 OpenCode 或 Aider（开源免费）。Codex CLI 也是不错的免费选择。</p>
<h4>IDE 用户 / 日常编码</h4>
<p>个人更倾向 Cursor：IDE 交互成熟，代码库索引能力较强。预算敏感可选 Windsurf（$10/月）或 Trae（免费）。</p>
<h4>GitHub 生态用户</h4>
<p>GitHub Copilot 是这一场景下的常见选择，与 GitHub 生态（PR 审查、Issue、Actions）绑定较深，替代成本较高。Agent Mode 也在持续增强。</p>
<h4>企业级 / 大型团队</h4>
<p>Augment Code 适合超大代码库（40万+文件）。Tabnine 适合对隐私有严格要求的企业。Amazon Q Developer 适合 AWS 深度用户。</p>
<h4>AWS 生态用户</h4>
<p>Kiro 的规格驱动开发方法论值得关注，与 AWS 服务深度集成。Amazon Q Developer 覆盖编码到运维全流程。</p>
<h4>中国开发者 / 预算敏感用户</h4>
<p>阿里云 Coding Plan 是价格较低的选择，一个订阅即可切换 Qwen3.5、GLM-5、MiniMax M2.5、Kimi K2.5 等多款模型，首月低至 ¥7.9。搭配 Claude Code 或 Cline 等客户端使用，可大幅降低 AI 编程成本。Trae（字节跳动）则提供完全免费的 AI IDE 体验。</p>
<h3>7.2 2026 年趋势展望</h3>
<ul>
<li><strong>Agent 化：</strong> 从辅助补全到自主执行，AI 编程工具正在从「副驾驶」变成「自动驾驶」</li>
<li><strong>多模型支持：</strong> 几乎所有工具都在走向模型无关，用户可自由选择最适合的模型</li>
<li><strong>MCP 协议普及：</strong> Model Context Protocol 正在成为 AI 工具连接外部服务的标准</li>
<li><strong>终端 vs IDE 分化：</strong> 终端 Agent 适合自动化和高级用户，IDE 适合日常交互式开发</li>
<li><strong>开源崛起：</strong> Cline、OpenCode、Aider 等开源工具正在缩小与商业产品的差距</li>
<li><strong>企业合规：</strong> SOC 2、ISO 认证成为企业采购的硬性要求</li>
<li><strong>国产模型崛起：</strong> GLM-5（744B）、MiniMax M2.5（230B）、Qwen3.5 等国产模型编码能力快速追赶，阿里云 Coding Plan 等平台以极低价格提供多模型订阅</li>
</ul>
<p>总结：2026 年的 AI 编程工具市场已经高度成熟和专业化。没有一个工具能满足所有场景，许多开发者会同时使用 2-3 个工具来覆盖不同需求。选择工具时，应根据自身的工作流、预算、隐私要求和技术栈来综合考量。</p>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[gradle学习]]></title>
            <link>https://critas.wang/posts/gradle%E5%AD%A6%E4%B9%A0/</link>
            <guid isPermaLink="false">https://critas.wang/posts/gradle%E5%AD%A6%E4%B9%A0/</guid>
            <pubDate>Fri, 26 Jan 2018 00:00:00 GMT</pubDate>
            <description><![CDATA[Gradle 构建工具学习笔记，包含 Maven 仓库配置与 Spring MVC 依赖管理。]]></description>
            <content:encoded><![CDATA[<blockquote>
<p>maven repository</p>
</blockquote>
<ul>
<li>http://maven.aliyun.com/nexus/content/groups/public</li>
</ul>
<pre><code>repositories {
    maven {
        url 'http://maven.aliyun.com/nexus/content/groups/public'
    }
}
</code></pre>
<hr />
<blockquote>
<p>spring mvc 配置</p>
</blockquote>
<pre><code>dependencies {
    //Version
    def springVersion = "4.3.7.RELEASE"
    def mybatisVersion = "3.4.2"

    // https://mvnrepository.com/artifact/org.springframework/spring-webmvc
    compile group: 'org.springframework', name: 'spring-webmvc', version: '$springVersion'
    // https://mvnrepository.com/artifact/org.mybatis/mybatis
    compile group: 'org.mybatis', name: 'mybatis', version: '$mybatisVersion'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}
</code></pre>
<hr />
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[ssh无密码登录]]></title>
            <link>https://critas.wang/posts/ssh%E6%97%A0%E5%AF%86%E7%A0%81%E7%99%BB%E5%BD%95/</link>
            <guid isPermaLink="false">https://critas.wang/posts/ssh%E6%97%A0%E5%AF%86%E7%A0%81%E7%99%BB%E5%BD%95/</guid>
            <pubDate>Fri, 26 Jan 2018 00:00:00 GMT</pubDate>
            <description><![CDATA[Linux 下使用 SSH 密钥对实现免密码登录的配置教程。]]></description>
            <content:encoded><![CDATA[<p>ssh 无密码登录要使用公钥与私钥。linux下可以用用ssh-keygen生成公钥/私钥对，下面我以CentOS为例。</p>
<p>有机器A(本机)，B(192.168.2.209)。现想A通过ssh免密码登录到B。</p>
<ol>
<li>在A机下生成公钥/私钥对。</li>
</ol>
<pre><code>ssh-keygen -t rsa -P ''
</code></pre>
<p>直接ssh-keygen然后三次回车就可以了。
-P表示密码，-P '' 就表示空密码，也可以不用-P参数，这样就要三车回车，用-P就一次回车。
它在/home/用户下生成.ssh目录，.ssh下有id_rsa和id_rsa.pub。</p>
<ol>
<li>把A机下的id_rsa.pub复制到B机下，在B机的.ssh/authorized_keys文件里</li>
</ol>
<ul>
<li>用scp复制。（如果B机器没有.ssh和authorized_keys文件则先创建这个文件夹和文件）</li>
</ul>
<pre><code>scp ~/.ssh/id_rsa.pub [用户名]@[IP]:/home/[用户名]/id_rsa.pub
</code></pre>
<p>id_rsa.pub                                    100%  223     0.2KB/s   00:00</p>
<p>由于还没有免密码登录的，所以要输入密码。</p>
<ol>
<li>B机把从A机复制的id_rsa.pub添加到.ssh/authorzied_keys文件里。</li>
</ol>
<pre><code>cat id_rsa.pub &gt;&gt; .ssh/authorized_keys
chmod 755 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
</code></pre>
<p>authorized_keys的权限要是600。</p>
<blockquote>
<p>无视2、3步，一步到位</p>
</blockquote>
<pre><code>ssh-copy-id -i ~/.ssh/id_rsa.pub [用户名]@[IP]
</code></pre>
<blockquote>
<p>mac安装 ssh-copy-id</p>
</blockquote>
<pre><code>curl -L https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/install.sh | sh
</code></pre>
<p>由于直接ssh [IP]不指定用户名，则会默认使用本机的用户名，为了使用固定用户名则采用以下方式</p>
<pre><code>cd ~/.ssh
vi config
</code></pre>
<p>键入以下格式内容</p>
<pre><code>Host    [别名]
        HostName        [IP]
        User            [用户名]
Host    [别名]
        HostName        [IP]
        User            [用户名]
</code></pre>
<p>输入完成如下</p>
<pre><code>Host    dev
        HostName        192.168.2.209
        User            root
Host    test
        HostName        192.168.2.225
        User            root
</code></pre>
<p>至此直接输入如下命令即可通过固定用户名免密码连接对应服务器</p>
<pre><code>ssh dev
</code></pre>
]]></content:encoded>
            <author>Critas</author>
        </item>
        <item>
            <title><![CDATA[supervisor进程守护]]></title>
            <link>https://critas.wang/posts/supervisor%E8%BF%9B%E7%A8%8B%E5%AE%88%E6%8A%A4/</link>
            <guid isPermaLink="false">https://critas.wang/posts/supervisor%E8%BF%9B%E7%A8%8B%E5%AE%88%E6%8A%A4/</guid>
            <pubDate>Fri, 26 Jan 2018 00:00:00 GMT</pubDate>
            <description><![CDATA[Supervisor 进程守护工具的安装、配置与使用，涵盖 CentOS 6/7 自启动配置及 Nginx、Redis、MongoDB 等服务的管理。]]></description>
            <content:encoded><![CDATA[<blockquote>
<p>1、安装与启动</p>
</blockquote>
<ul>
<li>yum 安装</li>
</ul>
<pre><code>yum install supervisor
</code></pre>
<ul>
<li>easy_install 安装</li>
</ul>
<pre><code>wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | sudo python

easy_install supervisor
</code></pre>
<ul>
<li>配置supervisor</li>
</ul>
<p>在etc下创建目录，并赋权限</p>
<pre><code>mkdir -m 700 -p /etc/supervisor
</code></pre>
<p>在目录" /etc/supervisor"下创建配置文件</p>
<pre><code>echo_supervisord_conf &gt; /etc/supervisor/supervisord.conf
</code></pre>
<p>修改配置文件</p>
<pre><code>vi /etc/supervisor/supervisord.conf
</code></pre>
<p>在文件末尾添加，注意首尾需无空格，需顶格</p>
<pre><code>[include]
files = /root/supervisorConf/*.conf
</code></pre>
<p>在目录"/etc/supervisor"下创建dotnet core 进程配置文件存放目录"conf.d"</p>
<pre><code>mkdir -m 700 /root/supervisorConf
</code></pre>
<p>如果需要在web控制台管理,则找到以下代码</p>
<pre><code>;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)
;username=user              ; (default is no username (open server))
;password=123               ; (default is no password (open server))
</code></pre>
<p>修改代码，删除前面的分号，port改为*:9001</p>
<pre><code>[inet_http_server]         ; inet (TCP) server disabled by default
port=*:9001        ; ip_address:port specifier, *:port for all ifa
username=user              ; default is no username (open server)
password=123               ; default is no password (open server)
</code></pre>
<hr />
<ul>
<li>配置supervisor自动启动</li>
</ul>
<h2>centos6</h2>
<p>设定supervisor启动文件</p>
<pre><code>vi /etc/init.d/supervisord
</code></pre>
<p>粘贴以下内容</p>
<pre><code>#! /usr/bin/env bash
# chkconfig: - 85 15

PATH=/sbin:/bin:/usr/sbin:/usr/bin

PROGNAME=supervisord

DAEMON=/usr/bin/$PROGNAME

CONFIG=/etc/supervisor/$PROGNAME.conf

PIDFILE=/tmp/$PROGNAME.pid

DESC="supervisord daemon"

SCRIPTNAME=/etc/init.d/$PROGNAME

# Gracefully exit if the package has been removed.

test -x $DAEMON || exit 0


start()

{

echo -n "Starting $DESC: $PROGNAME"

$DAEMON -c $CONFIG

echo ".............start success"

}

stop()

{

echo "Stopping $DESC: $PROGNAME"

if [ -f "$PIDFILE" ];
then
supervisor_pid=$(cat $PIDFILE)
kill -15 $supervisor_pid
echo "......"
echo "stop success"
else
echo "$DESC: $PROGNAME is not Runing"
echo ".........................stop sucess"
fi
}

status()

{ statusport=`netstat -lntp|grep 9001|awk -F ' ' '{print $4}'|awk -F ':' '{print $2}'`

if [ -f "$PIDFILE" ];
then
supervisor_pid=$(cat $PIDFILE)
echo "$DESC: $PROGNAME is Runing pid=$supervisor_pid"
else
echo "$DESC: $PROGNAME is not Runing"
echo "please use command /etc/init.d/supervisord start Run the service"
fi
}

case "$1" in

start)

start

;;

stop)

stop

;;

restart)

stop

start

;;

status)

status

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|restart}" &gt;&amp;2

exit 1

;;

esac

exit 0
</code></pre>
<p>添加自启动服务</p>
<pre><code>chkconfig supervisord  on
</code></pre>
<p>启动服务</p>
<pre><code>service supervisord start
</code></pre>
<p>停止服务</p>
<pre><code>service supervisord stop
</code></pre>
<h2>centos7</h2>
<p>创建supervisor 自启动服务</p>
<pre><code>vi /etc/systemd/system/supervisor.service
</code></pre>
<p>编辑内容：</p>
<pre><code>[Unit]
Description=supervisor

[Service]
Type=forking
ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl shutdown
ExecReload=/usr/bin/supervisorctl reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
</code></pre>
<p>使配置生效</p>
<pre><code>systemctl daemon-reload
</code></pre>
<p>设置服务开机启动，即设置enable</p>
<pre><code>systemctl enable supervisor.service
</code></pre>
<p>启动服务</p>
<pre><code>systemctl start supervisor.service
</code></pre>
<blockquote>
<p>2、参考配置</p>
</blockquote>
<ul>
<li>
<p>/etc/supervisor/supervisord.conf</p>
<p>在文件最后添加</p>
</li>
</ul>
<pre><code>[include]
files = /root/supervisorConf/*.conf
</code></pre>
<ul>
<li>/etc/supervisor/mongo.conf</li>
</ul>
<pre><code>[program:mongo]
command=/home/mongodb/mongodb-linux/bin/mongod --dbpath /home/mongodb/mongodb-linux/data
stderr_logfile=/var/log/mongo.error.log
stdout_logfile=/var/log/mongo.stdout.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
redirect_stderr=true
startsecs=3
</code></pre>
<ul>
<li>/etc/supervisor/mysql.conf</li>
</ul>
<pre><code>[program:mysql]
command=/usr/local/mysql/bin/mysqld_safe --defaults-file=/mysql/3306/my.cnf
stderr_logfile=/var/log/mongo.error.log
stdout_logfile=/var/log/mongo.stdout.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
redirect_stderr=true
startsecs=3
</code></pre>
<p>supervisor 监控的进程必须以非daemon 方式运行</p>
<p>如Nginx要用supervisor 管理需要在配置文件增加一行</p>
<ul>
<li>/opt/nginx/conf/nginx.conf</li>
</ul>
<pre><code>daemon off;
</code></pre>
<ul>
<li>/etc/supervisor/nginx.conf</li>
</ul>
<pre><code>[program:nginx]
command=/usr/local/nginx/sbin/nginx
directory=/usr/local/nginx
stderr_logfile=/var/log/nginx.error.log
stdout_logfile=/var/log/nginx.stdout.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
redirect_stderr=true
startsecs=3
</code></pre>
<ul>
<li>/etc/supervisor/redis.conf</li>
</ul>
<pre><code>[program:redis]
command=/usr/local/bin/redis-server /opt/redis/redis.conf
stderr_logfile=/var/log/Redis.error.log
stdout_logfile=/var/log/Redis.stdout.log
environment=ASPNETCORE_ENVIRONMENT=Production
user=root
stopsignal=INT
autostart=true
autorestart=true
redirect_stderr=true
startsecs=3
</code></pre>
<blockquote>
<p>3、其他</p>
</blockquote>
<p>更新新的配置到supervisord：</p>
<pre><code>supervisorctl update
</code></pre>
<p>更新新的配置到supervisord</p>
<pre><code>supervisorctl update
</code></pre>
<p>重新启动配置中的所有程序</p>
<pre><code>supervisorctl reload
</code></pre>
<p>启动某个进程(program_name=你配置中写的程序名称)</p>
<pre><code>supervisorctl start program_name
</code></pre>
<p>查看正在守候的进程</p>
<pre><code>supervisorctl
</code></pre>
<p>停止某一进程 (program_name=你配置中写的程序名称)</p>
<pre><code>pervisorctl stop program_name
</code></pre>
<p>重启某一进程 (program_name=你配置中写的程序名称)</p>
<pre><code>supervisorctl restart program_name
</code></pre>
<p>停止全部进程</p>
<pre><code>supervisorctl stop all
</code></pre>
]]></content:encoded>
            <author>Critas</author>
        </item>
    </channel>
</rss>