Skip to content

Fix/utf8 sanitization ingestion#140

Merged
xe-nvdk merged 4 commits intomainfrom
fix/utf8-sanitization-ingestion
Jan 19, 2026
Merged

Fix/utf8 sanitization ingestion#140
xe-nvdk merged 4 commits intomainfrom
fix/utf8-sanitization-ingestion

Conversation

@xe-nvdk
Copy link
Copy Markdown
Member

@xe-nvdk xe-nvdk commented Jan 19, 2026

No description provided.

xe-nvdk and others added 4 commits January 19, 2026 11:34
#136)

Users ingesting rsyslog messages or data with non-UTF-8 characters
experienced DuckDB query errors. This adds automatic UTF-8 sanitization
during ingestion.

Changes:
- Add SanitizeUTF8() function that replaces invalid UTF-8 bytes with U+FFFD
- Apply sanitization to MessagePack string fields (columnar and row formats)
- Apply sanitization to Line Protocol string field values
- Batch-level warning logs when sanitization occurs

Performance:
- Valid UTF-8 (99%+ of data): ~6-25ns overhead, zero allocations
- Invalid UTF-8 (rare): ~150-230ns with minimal allocations
Extended timestamp auto-detection to recognize nanosecond precision,
which is particularly important for users migrating from InfluxDB.

Previously, nanosecond timestamps (19-digit values) were incorrectly
treated as microseconds, resulting in dates far in the future.

Detection ranges:
- Seconds: < 1e10 (10 digits) → multiply by 1,000,000
- Milliseconds: < 1e13 (13 digits) → multiply by 1,000
- Microseconds: < 1e16 (16 digits) → no conversion
- Nanoseconds: >= 1e16 (19 digits) → divide by 1,000

Note: Line Protocol already correctly handles nanoseconds per InfluxDB spec.
Added benchmarks to compare different fast-path strategies for UTF-8
validation. Results show Go's utf8.ValidString() is already SIMD-optimized
and outperforms naive byte-scanning approaches.

Benchmark results on M3 Max:
- utf8.ValidString (short ASCII): 6.2 ns
- utf8.ValidString (long ASCII): 10.3 ns
- hasHighBit byte scan (short): 10.9 ns
- hasHighBit byte scan (long): 41.5 ns

Conclusion: Current implementation is already optimal.
@xe-nvdk xe-nvdk merged commit 5a0d16d into main Jan 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant