BladeX-Links合并1.1.0版本代码后,启动Server后提示TDEngine错误

Blade 未结 3 330
HoChau
HoChau 2024-09-25 10:22

一、该问题的重现步骤是什么?

 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版本

四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

3条回答
  •  如梦技术
    2024-09-25 15:48

    把 message 字段的长度改小点试试,td 一个表有总字段长度限制,我们这边是拿 3.3 的开发测试的。

    你直接用 taos 客户端工具调整并执行这个 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));

    调试 ok 了再去改 java 代码,也欢迎反馈一下具体结果。我们也尽量兼容一下。


    作者追问:2024-09-25 15:48

    调用如下方法,报错

    private final ITsDBDeviceDataService deviceDataService;

    deviceDataService.saveDeviceProperty(topicVariables, params);



    2024-09-25 17:50:21.483 ERROR 37260 --- [pool-2-thread-1] o.s.iot.core.task.BaseBatchTask          : 批量消费失败,数据可能会丢失


    org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO `device_property_ynobza0rumw_05eamkxm3c2n9elf` USING `device_property_ynobza0rumw` TAGS ('YNobza0rUMW', '05eAmkXm3c2n9eLF') (`time`, `usedNetPort`, `usedSerialPort`, `tx`, `ifname`, `rx`, `DISK_OC`, `TOTAL_MEM`, `AVAILABLE_MEM`, `FREE_MEM`, `CPU_OC`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `device_property_f4cmyfwsqs8_sehlbqozxm3o0z43` USING `device_property_f4cmyfwsqs8` TAGS ('F4CmYFWSqS8', 'seHlBqozxM3O0z43') (`time`, `T_In_c`, `In`, `T_In_a`, `T_In_b`, `Et`, `T`, `w_Pt`, `E_r_a`, `PFa`, `Ua`, `PFc`, `Ub`, `PFb`, `Uc`, `a_Pt`, `T_b`, `T_a`, `Ia`, `Ib`, `T_c`, `Ic`, `Ea`, `Eb`, `Ec`, `PFt`, `gear`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);]; SQL state []; error code [9731]; TDengine ERROR (0x2603): sql: INSERT INTO `device_property_ynobza0rumw_05eamkxm3c2n9elf` USING `device_property_ynobza0rumw` TAGS ('YNobza0rUMW', '05eAmkXm3c2n9eLF') (`time`, `usedNetPort`, `usedSerialPort`, `tx`, `ifname`, `rx`, `DISK_OC`, `TOTAL_MEM`, `AVAILABLE_MEM`, `FREE_MEM`, `CPU_OC`) VALUES (1727257821300, '1/2', '2/5', '0', 'eth1', '0', 71, 3976568, 3804508, 3566352, 28) `device_property_f4cmyfwsqs8_sehlbqozxm3o0z43` USING `device_property_f4cmyfwsqs8` TAGS ('F4CmYFWSqS8', 'seHlBqozxM3O0z43') (`time`, `T_In_c`, `In`, `T_In_a`, `T_In_b`, `Et`, `T`, `w_Pt`, `E_r_a`, `PFa`, `Ua`, `PFc`, `Ub`, `PFb`, `Uc`, `a_Pt`, `T_b`, `T_a`, `Ia`, `Ib`, `T_c`, `Ic`, `Ea`, `Eb`, `Ec`, `PFt`, `gear`) VALUES (1727257821316, 0.0, 0.0, 32.5, 0.0, 0.0, 33.6, 0.0, 0.0, 1.0, 230.22, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);, 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_property_ynobza0rumw_05eamkxm3c2n9elf` USING `device_property_ynobza0rumw` TAGS ('YNobza0rUMW', '05eAmkXm3c2n9eLF') (`time`, `usedNetPort`, `usedSerialPort`, `tx`, `ifname`, `rx`, `DISK_OC`, `TOTAL_MEM`, `AVAILABLE_MEM`, `FREE_MEM`, `CPU_OC`) VALUES (1727257821300, '1/2', '2/5', '0', 'eth1', '0', 71, 3976568, 3804508, 3566352, 28) `device_property_f4cmyfwsqs8_sehlbqozxm3o0z43` USING `device_property_f4cmyfwsqs8` TAGS ('F4CmYFWSqS8', 'seHlBqozxM3O0z43') (`time`, `T_In_c`, `In`, `T_In_a`, `T_In_b`, `Et`, `T`, `w_Pt`, `E_r_a`, `PFa`, `Ua`, `PFc`, `Ub`, `PFb`, `Uc`, `a_Pt`, `T_b`, `T_a`, `Ia`, `Ib`, `T_c`, `Ic`, `Ea`, `Eb`, `Ec`, `PFt`, `gear`) VALUES (1727257821316, 0.0, 0.0, 32.5, 0.0, 0.0, 33.6, 0.0, 0.0, 1.0, 230.22, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);, 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


    作者追问:2024-09-25 15:48

    1.0.0版本,使用的是Influxdb时序库,调用deviceDataService.saveDeviceProperty(topicVariablesparams);都没问题的,为什么升级到1.1.0版本,使用TDengine时序库,调用deviceDataService.saveDeviceProperty(topicVariablesparams)就会报表不存在


    org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO `device_property_ynobza0rumw_05eamkxm3c2n9elf` USING `device_property_ynobza0rumw` TAGS ('YNobza0rUMW', '05eAmkXm3c2n9eLF') (`time`, `usedNetPort`, `usedSerialPort`, `tx`, `ifname`, `rx`, `DISK_OC`, `TOTAL_MEM`, `AVAILABLE_MEM`, `FREE_MEM`, `CPU_OC`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) `device_property_f4cmyfwsqs8_sehlbqozxm3o0z43` USING `device_property_f4cmyfwsqs8` TAGS ('F4CmYFWSqS8', 'seHlBqozxM3O0z43') (`time`, `T_In_c`, `In`, `T_In_a`, `T_In_b`, `Et`, `T`, `w_Pt`, `E_r_a`, `PFa`, `Ua`, `PFc`, `Ub`, `PFb`, `Uc`, `a_Pt`, `T_b`, `T_a`, `Ia`, `Ib`, `T_c`, `Ic`, `Ea`, `Eb`, `Ec`, `PFt`, `gear`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);]; SQL state []; error code [9731]; TDengine ERROR (0x2603): sql: INSERT INTO `device_property_ynobza0rumw_05eamkxm3c2n9elf` USING `device_property_ynobza0rumw` TAGS ('YNobza0rUMW', '05eAmkXm3c2n9eLF') (`time`, `usedNetPort`, `usedSerialPort`, `tx`, `ifname`, `rx`, `DISK_OC`, `TOTAL_MEM`, `AVAILABLE_MEM`, `FREE_MEM`, `CPU_OC`) VALUES (1727257821300, '1/2', '2/5', '0', 'eth1', '0', 71, 3976568, 3804508, 3566352, 28) `device_property_f4cmyfwsqs8_sehlbqozxm3o0z43` USING `device_property_f4cmyfwsqs8` TAGS ('F4CmYFWSqS8', 'seHlBqozxM3O0z43') (`time`, `T_In_c`, `In`, `T_In_a`, `T_In_b`, `Et`, `T`, `w_Pt`, `E_r_a`, `PFa`, `Ua`, `PFc`, `Ub`, `PFb`, `Uc`, `a_Pt`, `T_b`, `T_a`, `Ia`, `Ib`, `T_c`, `Ic`, `Ea`, `Eb`, `Ec`, `PFt`, `gear`) VALUES (1727257821316, 0.0, 0.0, 32.5, 0.0, 0.0, 33.6, 0.0, 0.0, 1.0, 230.22, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);, desc: Table does not exist

    作者追问:2024-09-25 15:48

    用了TDengine后需要发布物模型才会创建超级表,具体看这里:https://iot.bladex.cn/tech/prologue/tsdb/tsdb.html#%E4%BA%8C%E3%80%81tdengine-%E9%85%8D%E7%BD%AE


    CleanShot20240926094843@2x.png

    作者追问:2024-09-25 15:48

    image.png


    这里是什么意思,1.0.0版本使用的是influxdb,已创建物模型,设备数据可以正常入库的。现在升级到1.1.0版本,使用 TDEngine,编辑产品的物模型重新发布了,还是提示表不存在,要怎么处理?

    作者追问:2024-09-25 15:48

    1.1.0开始在发布物模型的时候tdengine会创建超级表,根据下面的图打断点看看表有没有创建成功,进入tdengine控制台看看超级表的目录有哪些。

    另外为了防止升级合并遗漏的可能性,建议临时下载一个git私服最新版然后运行。启动成功后进入对应的两个产品发布物模型,再用设备模拟器测试上报数据,看下是否能成功。

    CleanShot20240926143351@2x.png

    CleanShot20240926143437@2x.png

    作者追问:2024-09-25 15:48

    image.png


    执行了还是不行

    作者追问:2024-09-25 15:48

    image.png


    看到有这张表

    作者追问:2024-09-25 15:48

    tdengine版本是多少,用git私服最新的原版跑一下,看看结果是多少。如果原版在tdengine3.3.0.3以上版本跑都没有效果,麻烦录个视频,看下你的具体操作步骤。发到邮箱 bladejava@qq.com

    作者追问:2024-09-25 15:48

    SQL state []; error code [9731]; TDengine ERROR (0x2603): sql: INSERT INTO `device_property_ynobza0rumw_05eamkxm3c2n9elf` USING `device_property_ynobza0rumw` TAGS ('YNobza0rUMW', '05eAmkXm3c2n9eLF')


    这个表没创建:device_property_ynobza0rumw,你再操作下。你提供的信息有点多,把成功的表也贴出来当作错误日志了。

提交回复