apache / apache/iotdb

[Bug] 2.0.2版本 设置设备模板后,插入数据报错

Open
#15,435 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.4k
Forks
1.2k
Avg merge
1d 23h
Merged PRs (30d)
115

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/iotdb/issues) and found nothing similar.

### Version

2.0.2

### Describe the bug and provide the minimal reproduce step

1.创建设备模板
2.挂载设备模板
3.使用maven项目引入依赖

org.apache.iotdb
iotdb-session
2.0.2

4.使用以下方法插入设备数据
sessionPool.insertRecord(deviceId, time, measurements, tsTypes, values);

### What did you expect to see?

数据成功插入到数据库

### What did you see instead?

iotdb数据库报错日志

2025-04-29 11:17:54,999 [pool-56-IoTDB-ClientRPC-Processor-1$20250429_031754_00048_1.1.0] WARN o.a.i.d.q.p.s.FragmentInstanceDispatcherImpl:514 - write locally failed. TSStatus: TSStatus(code:305, message:internal error. statemachine throws a runtime exception: java.lang.NullPointerException), message: internal error. statemachine throws a runtime exception: java.lang.NullPointerException
2025-04-29 11:18:55,506 [1@group-000200000009-StateMachineUpdater] ERROR o.a.i.c.r.ApplicationStateMachineProxy:157 - application statemachine throws a runtime exception:
java.lang.NullPointerException: null
at org.apache.iotdb.db.schemaengine.rescon.MemSchemaEngineStatistics.lambda$getTemplateSeriesNumber$0(MemSchemaEngineStatistics.java:142)
at java.util.stream.ReferencePipeline$5$1.accept(ReferencePipeline.java:227)
at java.util.concurrent.ConcurrentHashMap$EntrySpliterator.forEachRemaining(ConcurrentHashMap.java:3606)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.LongPipeline.reduce(LongPipeline.java:438)
at java.util.stream.LongPipeline.sum(LongPipeline.java:396)
at org.apache.iotdb.db.schemaengine.rescon.MemSchemaEngineStatistics.getTemplateSeriesNumber(MemSchemaEngineStatistics.java:144)
at org.apache.iotdb.db.schemaengine.rescon.MemSchemaEngineStatistics.getTotalSeriesNumber(MemSchemaEngineStatistics.java:124)
at org.apache.iotdb.db.schemaengine.rescon.MemSchemaRegionStatistics.getGlobalSeriesNumber(MemSchemaRegionStatistics.java:230)
at org.apache.iotdb.db.schemaengine.schemaregion.impl.SchemaRegionMemoryImpl.activateSchemaTemplate(SchemaRegionMemoryImpl.java:1358)
at org.apache.iotdb.db.consensus.statemachine.schemaregion.SchemaExecutionVisitor.visitActivateTemplate(SchemaExecutionVisitor.java:436)
at org.apache.iotdb.db.consensus.statemachine.schemaregion.SchemaExecutionVisitor.visitActivateTemplate(SchemaExecutionVisitor.java:94)
at org.apache.iotdb.db.queryengine.plan.planner.plan.node.metadata.write.ActivateTemplateNode.accept(ActivateTemplateNode.java:175)
at org.apache.iotdb.db.consensus.statemachine.schemaregion.SchemaRegionStateMachine.write(SchemaRegionStateMachine.java:182)
at org.apache.iotdb.consensus.ratis.ApplicationStateMachineProxy.applyTransaction(ApplicationStateMachineProxy.java:153)
at org.apache.ratis.server.impl.RaftServerImpl.applyLogToStateMachine(RaftServerImpl.java:1839)
at org.apache.ratis.server.impl.StateMachineUpdater.applyLog(StateMachineUpdater.java:255)
at org.apache.ratis.server.impl.StateMachineUpdater.run(StateMachineUpdater.java:193)
at java.lang.Thread.run(Thread.java:748)

### Anything else?

_No response_

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start with db/schemaengine/rescon/MemSchemaEngineStatistics.java at getTemplateSeriesNumber, especially line 142, then trace the activation path through SchemaRegionMemoryImpl.activateSchemaTemplate. Reproduce the device-template setup and sessionPool.insertRecord call against version 2.0.2; done means template activation no longer raises the NullPointerException and the data insert succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.