[fix] strip NUL bytes before tdengine history insert - #4310
Open
orangeCatDeveloper wants to merge 1 commit into
Open
[fix] strip NUL bytes before tdengine history insert#4310orangeCatDeveloper wants to merge 1 commit into
orangeCatDeveloper wants to merge 1 commit into
Conversation
Windows snmp interface descriptions carry NUL padding that made the hand-built INSERT fail with error 216 and lose the whole batch (apache#1481). Remove NUL from string values before escaping, and truncate the logical value before escaping so the cut cannot split an escape sequence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
Fixes #1481: Windows SNMP interface descriptions carry NUL padding bytes (
\^@). The TDengine history storage builds its INSERT by hand, so the NUL reached the SQL text, TDengine rejected it with error 216, and the whole batch was lost — including the healthy rows.Fix in
TdEngineDataStorage.formatStringValue, the single choke point all string values, labels json and the instance tag pass through:\u0000before anything else (only NUL — tabs/newlines are legitimate data)\'in half, leaving a dangling backslash that escapes the closing quote and kills the batch the same wayOnly TDengine is affected: the other history backends use typed clients / JSON / line protocol instead of hand-built SQL.
Verified against a real TDengine 3.3.5.0 with a metric whose string value ends in
\u0000(one poisoned row, one healthy row per batch):Before — every batch rejected, both rows lost:
After — no errors, both rows stored, NUL stripped:
Checklist
Add or update API