[BUG] TDengine encountered a write exception in version 1.8.0
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
[BUG] 版本1.8.0 TDengine DNS服务器监控 大量sql插入字段报错
2026-01-12T11:23:13.478987256+08:00 2026-01-12 11:23:13 [warehouse-persistent-data-storage] ERROR org.apache.hertzbeat.warehouse.store.history.tsdb.tdengine.TdEngineDataStorage - TDengine ERROR (216): sql: INSERT INTO dns_additional_10_1_1_1_53 USING dns_additional__super TAGS (10.1.1.1:53) VALUES (1768188193475, '{}', '{ . 0 CLASS1232 OPT [ ; payload 1232, xrcode 0, version 0, flags 0] }', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), desc: syntax error near '10.1.1.1:53) values (1768188193475, '{}', '{ . 0 CLASS1232 OPT' (invalid data or symbol)
2026-01-12T11:35:13.227277225+08:00 2026-01-12 11:35:13 [warehouse-persistent-data-storage] ERROR org.apache.hertzbeat.warehouse.store.history.tsdb.tdengine.TdEngineDataStorage - TDengine ERROR (216): sql: INSERT INTO dns_header_10_1_1_1_53 USING dns_header__super TAGS (10.1.1.1:53) VALUES (1768188913224, '{}', 37.0, 'QUERY', 'NOERROR', 'qr aa rd ra ', 1.0, 4.0, 0.0, 1.0), desc: syntax error near '10.1.1.1:53) values (1768188913224, '{}', 37.0, 'QUERY', 'NOER' (invalid data or symbol)
Expected Behavior
No response
Steps To Reproduce
No response
Environment
HertzBeat version(s): 1.8.0
Debug logs
No response
Anything else?
No response
tks! we will address this as soon as possible.
Hi, This appears to be due to the lack of necessary escaping for special characters (such as dots, colons) in the instance during insertion in the #3863 refactoring
I'd be happy to take care of the fix to save you some time. Would you like me to submit a PR @Duansg
Hi, This appears to be due to the lack of necessary escaping for special characters (such as dots, colons) in the instance during insertion in the #3863 refactoring
I'd be happy to take care of the fix to save you some time. Would you like me to submit a PR @Duansg
Ok, thanks, it is indeed due to the refactoring, but there are several issues that need attention.
- Failure due to incorrect insertion type
CREATE STABLE IF NOT EXISTS `%s` `%s` TAGS (monitor BIGINT)
- Even if the insertion is normal, the historical metrics will become invalid. The Prometheus application is accessed via
if (CommonConstants.PROMETHEUS.equals(monitor.getApp())) {
appDefine.setApp(CommonConstants.PROMETHEUS_APP_PREFIX + monitor.getName());
}
- The type of the TAG column is fixed. The official TDEngine documentation states:
You cannot modify tag columns of other types.Should we consider a fallback approach of rebuilding or guiding deletion?
@Saramanda9988 I'm not sure if the currently supported TSDB has similar issues. Could you please perform regression testing?
Hi @Duansg , Thanks for your trust. I’ve reviewed the code and current situation again, and here are my perspectives on the points you raised: For this bug, your guidance is correct. In my opinion, since the insertion has been consistently failing, the database is effectively in a "vacuum" state for affected users. Therefore, I believe there is no actual data loss for these users, and we also need to fix the query-related issue. For historical metrics migration, I’m not entirely sure how much users value historical data (e.g., last 7 days, 1 month, or longer). Actually, in my previous PR, I didnt try to do data migration so I tried to implement a "compatible query" approach —— querying twice, once by instance and once by monitorId, and merging the results. However, I felt the performance overhead was high for very low returns, so I removed it. Since I didn't receive specific guidance on this during that PR's review, I kept the current instance-only query logic. Referring to Issue #3765, it was mentioned by Tom that: "QuestDB, TDengine, and IoTDB are not in the plan for the future, I think we do not need to be compatible with these." Based on this, I believe guiding users to delete old/incompatible data is the better choice:
- Most TSDBs lack migration mechanisms like Flyway. Manual migration by users is prone to unnecessary data loss.
- This approach clearly communicates our future development roadmap to the community. Regarding other databases, I will coordinate with you to perform regression tests as needed to ensure system-wide stability. I'd love to hear your thoughts on this approach.
I'd love to hear your thoughts on this approach.
@Saramanda9988 Hi, thank you for your reply. Yes, TDengine is indeed not part of our long-term plans going forward. However, what I meant to convey is:
If you generate a table according to the new rules, even if you fix the type, the insertion will still fail because the table has already been created and its type cannot be modified, this is not a matter of historical data migration.
Adding a fallback strategy would require catching and handling exceptions. Since version 1.8.0 was just released, implementing such a heavyweight solution isn't necessary. Could we instead consider modifying the dynamic table name generation strategy? After all, this requires no additional user intervention.
Hi @Duansg ,thanks! I got it I completely agree with the dynamic table name generation strategy. What about introduceing a version suffix (e.g., _v2) to both the Super Table and Sub-table names like this:
If it's ok, I'll submit the PR soon.