Hi all,
I'd like to share a bug fix introduced by the following PR:
- master: https://github.com/apache/iotdb/pull/18814
IoTDB decides between the tree and the table data model in many storage
paths, and those decisions used to be made from IDeviceID.isTableModel(),
which only guessed the model from the device id string. Because a device id
carries no reliable model marker, that guess is wrong for some devices, and
the affected paths then take the wrong branch. This PR removes the API and
derives the data model from the context that actually owns it.
The root cause is that IDeviceID.isTableModel() is a naming convention
rather than the real data model:
- it returned !segments[0].startsWith("root."), i.e. it assumed every
tree-model device starts with root. and every table-model device does not;
- tree-model databases are not required to be named root.* and a table name
may use that prefix, so devices can be misjudged in both directions;
- memtable, flush, compaction, WAL replay, query modification filtering and
pipe all trusted that flag.
The fix derives the model explicitly from the owning context:
- memtable, flush and WAL replay APIs take an ignoreAllNullRows flag (the
tree-model notion) instead of querying the device id;
- compaction takes the model from the database directory of the source
files, query takes it from the query context, and the table TTL is looked
up with the data region's database name;
- pipe takes it from the event type, the tsfile database or
isTableModelEvent();
- ImportWAL refuses to replay a non-empty snapshot when the target database
(hence the model) is unknown, and declares the WAL node allocation
strategies it cannot import.
Main changes include:
- removed the IDeviceID.isTableModel() call sites and bumped tsfile.version
to the snapshot that drops the method;
- added an explicit data-model / ignoreAllNullRows parameter to IMemTable,
IWritableMemChunk, IWritableMemChunkGroup and the flush/WAL paths;
- annotated the tree/table-model-only APIs in PartitionCache and added
QueryContext.isTableModel();
- updated the pipe matchers/builders and the ImportWAL tool (new -db
requirement);
- updated the affected unit tests, whose compaction fixtures now live in a
table-model database.
Feedback and suggestions are welcome.

大家好,
我想分享以下 PR 中修复的一个 bug:
- master:https://github.com/apache/iotdb/pull/18814
IoTDB 在很多存储路径上都要判断当前是树模型还是表模型,而这些判断以往都由 IDeviceID.isTableModel() 给出,它只是从
device id 字符串去"猜"数据模型。device id 本身并不携带可靠的模型标识,因此对某些 device
会猜错,相关路径随后就会走到错误的分支上。这个 PR 移除了该 API,改为从真正掌握该信息的上下文里推导数据模型。
根本原因在于 IDeviceID.isTableModel() 依赖的是命名约定,而不是真实的数据模型:
- 它的实现是 !segments[0].startsWith("root."),即默认树模型 device 都以 root. 开头、表模型
device 都不以 root. 开头;
- 但树模型数据库并不要求命名为 root.*,表名也可能使用该前缀,两个方向都可能误判;
- memtable、flush、compaction、WAL 回放、查询修改过滤和 pipe 都信任了这个标志。
本次修复改为从所属上下文显式推导数据模型:
- memtable、flush 和 WAL 回放的接口改为接收 ignoreAllNullRows 标志(即树模型语义),不再查询 device
id;
- compaction 从源文件所在的数据库目录取模型,查询从查询上下文取模型,表 TTL 用 DataRegion 的数据库名来查找;
- pipe 从事件类型、tsfile 所属数据库或 isTableModelEvent() 判断;
- ImportWAL 在目标数据库(因而数据模型)未知时拒绝回放非空快照,并声明其无法导入的 WAL 节点分配策略。
主要修改包括:
- 移除了 IDeviceID.isTableModel() 的所有调用点,并将 tsfile.version 升级到移除该方法的快照;
- 为 IMemTable、IWritableMemChunk、IWritableMemChunkGroup 及 flush/WAL
路径增加了显式的数据模型 / ignoreAllNullRows 参数;
- 为 PartitionCache 中仅适用于树/表模型的接口加上标注,并新增 QueryContext.isTableModel();
- 更新了 pipe 的 matcher/builder 以及 ImportWAL 工具(新增 -db 要求);
- 更新了受影响的单元测试,其中 compaction 测试的 fixture 现在放在表模型数据库中。
欢迎大家提出反馈和建议。
Best regards,
Wenwei Shu

Reply via email to