一、该问题的重现步骤是什么?
BladeX-Links合并1.1.0版本代码后,启动Server后提示:
2024-09-25 10:14:07.212 INFO 17960 --- [ main] o.s.i.t.tdengine.dao.TDEngineTemplate : TdEngine create database sql:CREATE DATABASE IF NOT EXISTS links PRECISION 'ms' CACHEMODEL 'last_value' KEEP 3650 DURATION 10 BUFFER 16 WAL_LEVEL 1
2024-09-25 10:14:08.351 INFO 17960 --- [ main] o.s.i.t.tdengine.dao.TDEngineTemplate : TdEngine create STable sql:CREATE STABLE IF NOT EXISTS device_logger (`time` timestamp, `topic` NCHAR(128), `message` NCHAR(8192)) TAGS (`product_key` NCHAR(64), `device_name` NCHAR(64));
2024-09-25 10:14:08.354 INFO 17960 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-2} inited
2024-09-25 10:14:08.408 ERROR 17960 --- [ main] o.s.i.t.tdengine.dao.TDEngineTemplate : TdEngine create STable error
org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [CREATE STABLE IF NOT EXISTS device_logger (`time` timestamp, `topic` NCHAR(128), `message` NCHAR(8192)) TAGS (`product_key` NCHAR(64), `device_name` NCHAR(64));]; SQL state []; error code [9794]; TDengine ERROR (0x2642): sql: CREATE STABLE IF NOT EXISTS device_logger (`time` timestamp, `topic` NCHAR(128), `message` NCHAR(8192)) TAGS (`product_key` NCHAR(64), `device_name` NCHAR(64));, desc: Invalid binary/nchar column length
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1549)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:408)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:444)
at org.springblade.iot.tsdb.tdengine.dao.TDEngineTemplate.createSTable(TDEngineTemplate.java:318)
at org.springblade.iot.tsdb.tdengine.dao.TDEngineTemplate.afterSingletonsInstantiated(TDEngineTemplate.java:449)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:986)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:971)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:625)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:456)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:335)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:149)
at org.springblade.core.launch.BladeApplication.run(BladeApplication.java:49)
at org.springblade.mqtt.broker.BrokerApplication.main(BrokerApplication.java:43)
Caused by: java.sql.SQLException: TDengine ERROR (0x2642): sql: CREATE STABLE IF NOT EXISTS device_logger (`time` timestamp, `topic` NCHAR(128), `message` NCHAR(8192)) TAGS (`product_key` NCHAR(64), `device_name` NCHAR(64));, desc: Invalid binary/nchar column length
at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:95)
at com.taosdata.jdbc.rs.RestfulStatement.execute(RestfulStatement.java:97)
at com.taosdata.jdbc.rs.RestfulStatement.execute(RestfulStatement.java:78)
at com.alibaba.druid.pool.DruidPooledStatement.execute(DruidPooledStatement.java:635)
at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:435)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:393)
... 13 common frames omitted
二、你期待的结果是什么?实际看到的又是什么?
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
使用BladeX-Links,更新到1.1.0版本
四、请提供详细的错误堆栈信息,这很重要。
五、若有更多详细信息,请在下面提供。
tdengine版本是3.0.1.4,有没可能是版本低了,要求最低版本是多少。还有,没看明白“用git私服最新的原版跑一下”是什么意思
我们的回复好好看啊,不然只看个头或者尾巴很难解决问题的
拉了blade_dev版本下来,只修改了broker和simulator模块的yml配置文件,跑broker还是报表Table does not exist错误:
1、rabbitmq错误
com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:395)
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:71)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:165)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1242)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1198)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1156)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1321)
at org.springblade.mqtt.broker.data.relay.handler.ServerRelayHandler.lambda$getAmqpConnection$6(ServerRelayHandler.java:266)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at org.springblade.mqtt.broker.data.relay.handler.ServerRelayHandler.getAmqpConnection(ServerRelayHandler.java:259)
at org.springblade.mqtt.broker.data.relay.handler.ServerRelayHandler.getAmqpChannel(ServerRelayHandler.java:282)
at org.springblade.mqtt.broker.data.relay.config.DefaultServerRelayManager.forwardMessage(DefaultServerRelayManager.java:96)
at org.springblade.mqtt.broker.data.relay.config.DefaultServerRelayManager.lambda$execute$0(DefaultServerRelayManager.java:77)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at org.springblade.mqtt.broker.data.relay.config.DefaultServerRelayManager.lambda$execute$1(DefaultServerRelayManager.java:71)
at java.base/java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603)
at org.springblade.mqtt.broker.data.relay.config.DefaultServerRelayManager.lambda$execute$2(DefaultServerRelayManager.java:69)
at java.base/java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603)
at org.springblade.mqtt.broker.data.relay.config.DefaultServerRelayManager.execute(DefaultServerRelayManager.java:65)
at org.springblade.mqtt.broker.data.listener.BladeMqttMessageListener.executeServerRelayManager(BladeMqttMessageListener.java:98)
at org.springblade.mqtt.broker.data.listener.BladeMqttMessageListener.onMessage(BladeMqttMessageListener.java:74)
at org.springblade.mqtt.broker.data.listener.BladeMqttFunctionMessageListener.execMqttFunction(BladeMqttFunctionMessageListener.java:83)
at org.springblade.mqtt.broker.data.listener.BladeMqttFunctionMessageListener.lambda$onMessage$0(BladeMqttFunctionMessageListener.java:70)
at org.springblade.core.boot.tenant.TenantIdUtil.use(TenantIdUtil.java:74)
at org.springblade.mqtt.broker.data.listener.BladeMqttFunctionMessageListener.onMessage(BladeMqttFunctionMessageListener.java:69)
at net.dreamlu.iot.mqtt.core.server.support.DefaultMqttServerProcessor.lambda$invokeListenerForPublish$4(DefaultMqttServerProcessor.java:503)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
2、插入设备属性数据错误
2024-09-27 10:30:42.901 ERROR 35336 --- [pool-2-thread-1] o.s.iot.core.task.BaseBatchTask : 批量消费失败,数据可能会丢失
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL
[INSERT INTO `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn')
(`time`, `topic`, `message`) VALUES (?, ?, ?) `device_property_jkerjk97oub_27oy29bmmln` USING `device_property_jkerjk97oub` TAGS
('JkerjK97oub', '27OY29BMmLn') (`time`, `LightSwitch`, `BatteryLevel`) VALUES (?, ?, ?)
`device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn')
(`time`, `topic`, `message`) VALUES (?, ?, ?) `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger`
TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (?, ?, ?) `device_logger_jkerjk97oub_27oy29bmmln`
USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (?, ?, ?)
`device_command_jkerjk97oub_27oy29bmmln` USING `device_command` TAGS ('JkerjK97oub', '27OY29BMmLn')
(`time`, `output`, `input`, `identifier`, `commandName`) VALUES (?, ?, ?, ?, ?)
`device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn')
(`time`, `topic`, `message`) VALUES (?, ?, ?) `device_event_jkerjk97oub_27oy29bmmln` USING `device_event`
TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `output`, `identifier`, `eventName`, `eventType`) VALUES (?, ?, ?, ?, ?)
`device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`)
VALUES (?, ?, ?);]; SQL state []; error code [9731]; TDengine ERROR (0x2603): sql: INSERT INTO `device_logger_jkerjk97oub_27oy29bmmln`
USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242467, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/event/property/post', '{"id":"b1485004447468dfba726459bb9b5103","version":"1.0","params":{"LightSwitch":"1","BatteryLevel":20}}') `device_property_jkerjk97oub_27oy29bmmln` USING `device_property_jkerjk97oub` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `LightSwitch`, `BatteryLevel`) VALUES (1727404242467, '1', 20) `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242467, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/event/property/post', '{"id":"b1485004447468dfba726459bb9b5103","version":"1.0","params":{"LightSwitch":"1","BatteryLevel":20}}') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242478, '/blade/ext/ntp/JkerjK97oub/27OY29BMmLn/response', '{"deviceSendTime":"1727404162904","serverRecvTime":"1727404242477","serverSendTime":"1727404242477"}') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242478, '/blade/ext/ntp/JkerjK97oub/27OY29BMmLn/request', '{"deviceSendTime":"1727404162904"}') `device_command_jkerjk97oub_27oy29bmmln` USING `device_command` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `output`, `input`, `identifier`, `commandName`) VALUES (1727404242489, '{"RebootTime":1727404162848}', '{"RebootStatus":"true"}', 'Reboot', '重启服务') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242489, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/service/Reboot', '{"id":"c27962752d26b862552a889a396cff89","version":"1.0","params":{"output":"{\"RebootTime\":1727404162848}","input":"{\"RebootStatus\":\"true\"}","commandName":"重启服务"}}') `device_event_jkerjk97oub_27oy29bmmln` USING `device_event` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `output`, `identifier`, `eventName`, `eventType`) VALUES (1727404242500, '{"BatteryLevel":20}', 'LowBatteyEvent', '电量低事件', 'alert') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242500, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/event/LowBatteyEvent/post', '{"id":"e122e2386aba5e31a6cfef6d02c36769","version":"1.0","params":{"output":"{\"BatteryLevel\":20}","eventName":"电量低事件","eventType":"alert"}}');, desc: Table does not exist
at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1549)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:677)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:970)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:1014)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:1024)
at org.springblade.iot.tsdb.tdengine.dao.TDEngineTemplate.saveBatch(TDEngineTemplate.java:84)
at org.springblade.iot.core.task.BaseBatchTask.consumerQueueData(BaseBatchTask.java:72)
at org.springblade.iot.core.task.BaseBatchTask$1.run(BaseBatchTask.java:53)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.sql.SQLException: TDengine ERROR (0x2603): sql: INSERT INTO `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242467, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/event/property/post', '{"id":"b1485004447468dfba726459bb9b5103","version":"1.0","params":{"LightSwitch":"1","BatteryLevel":20}}') `device_property_jkerjk97oub_27oy29bmmln` USING `device_property_jkerjk97oub` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `LightSwitch`, `BatteryLevel`) VALUES (1727404242467, '1', 20) `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242467, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/event/property/post', '{"id":"b1485004447468dfba726459bb9b5103","version":"1.0","params":{"LightSwitch":"1","BatteryLevel":20}}') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242478, '/blade/ext/ntp/JkerjK97oub/27OY29BMmLn/response', '{"deviceSendTime":"1727404162904","serverRecvTime":"1727404242477","serverSendTime":"1727404242477"}') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242478, '/blade/ext/ntp/JkerjK97oub/27OY29BMmLn/request', '{"deviceSendTime":"1727404162904"}') `device_command_jkerjk97oub_27oy29bmmln` USING `device_command` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `output`, `input`, `identifier`, `commandName`) VALUES (1727404242489, '{"RebootTime":1727404162848}', '{"RebootStatus":"true"}', 'Reboot', '重启服务') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242489, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/service/Reboot', '{"id":"c27962752d26b862552a889a396cff89","version":"1.0","params":{"output":"{\"RebootTime\":1727404162848}","input":"{\"RebootStatus\":\"true\"}","commandName":"重启服务"}}') `device_event_jkerjk97oub_27oy29bmmln` USING `device_event` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `output`, `identifier`, `eventName`, `eventType`) VALUES (1727404242500, '{"BatteryLevel":20}', 'LowBatteyEvent', '电量低事件', 'alert') `device_logger_jkerjk97oub_27oy29bmmln` USING `device_logger` TAGS ('JkerjK97oub', '27OY29BMmLn') (`time`, `topic`, `message`) VALUES (1727404242500, '/blade/sys/JkerjK97oub/27OY29BMmLn/thing/event/LowBatteyEvent/post', '{"id":"e122e2386aba5e31a6cfef6d02c36769","version":"1.0","params":{"output":"{\"BatteryLevel\":20}","eventName":"电量低事件","eventType":"alert"}}');, desc: Table does not exist
at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:95)
at com.taosdata.jdbc.rs.RestfulStatement.execute(RestfulStatement.java:97)
at com.taosdata.jdbc.rs.RestfulStatement.execute(RestfulStatement.java:78)
at com.taosdata.jdbc.rs.RestfulStatement.executeUpdate(RestfulStatement.java:56)
at com.taosdata.jdbc.rs.RestfulPreparedStatement.executeUpdate(RestfulPreparedStatement.java:59)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeUpdate(DruidPooledPreparedStatement.java:241)
at org.springframework.jdbc.core.JdbcTemplate.lambda$update$2(JdbcTemplate.java:975)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658)
... 13 common frames omitted
代码分支
时序库版本
数据库已有相关表
1. 下载master分支:https://center.javablade.com/blade/BladeX-Links
2. tdengine 3.3以上版本
3. 重新创建数据库后跑起前后端,然后进入产品管理,把物模型重新发布
4. 查看tdengine有没有创建 device_property_xx 的表 (你的数据库只有device_comand、device_event、device_log,说明你没有操作物模型发布)
5. 有了之后再测试数据上报
6. 如果实在解决不了,可能难度有点高,建议你换回influxdb
扫一扫访问 Blade技术社区 移动端