fix(ducklake): data_extra double-encoded JSON broke Aleg correlation (#790) - #791
Merged
Merged
Conversation
Since the upstream duckdb-go/v2 bump (11.0.236), the Appender json.Marshal()s values for JSON columns, so passing data_extra as a Go string stored it as a JSON string scalar instead of an object. json_extract_string(data_extra, '$.x_call_id') then returned NULL and Lua call correlation silently found no peer legs (github.com//issues/790). - pass pooled and cached data_extra cells to the Appender as json.RawMessage - accept RawMessage/*[]byte data_extra in BuildInsertMultiValues (LP, PCAP import) - sip_call.lua: extract x_call_id from the data_extra JSON string and use the cid column when it differs from session_id, fixing B-leg -> A-leg lookup - upgrade unmodified legacy seed scripts in place (SHA256 fingerprint), preserving status; operator-edited scripts stay untouched - regression tests: Appender JSON round-trip (json_type must be OBJECT) and legacy seed upgrade
|
Alexandr Dubovikov seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.
Fixes #790.
Root cause
This is a regression introduced in v11.0.236 by the DuckDB 1.5.3 / upstream
duckdb-go/v2migration. As part of that bump, the HEP write path started passing thedata_extracell to the DuckDB Appender as a plain Go string. The upstream Appender runsjson.Marshal()on values destined for JSON columns, so the JSON object text got re-encoded into a JSON string scalar:The correlation script looks up peer legs with
json_extract_string(data_extra, '$.x_call_id'), which returnsNULLfor a string scalar, so the query succeeds but matches nothing. That's why the reporter saw no errors and no timeouts: the engine ran fine, correlated 0 rows, andcorrelation: reloaded scripts count=1was the only relevant log line. IncreasingHOMER_COORDINATOR_CORRELATION_*had no effect for the same reason.Fix
data_extrais now handed to the Appender asjson.RawMessage, which is stored verbatim as a JSON object (pooled SIP buffers and the cached simple/version-only cells).BuildInsertMultiValues(Line Protocol ingest, PCAP import) acceptsjson.RawMessageand pooled*[]bytedata_extra cells.sip_call.luanow extractsx_call_idfrom inside thedata_extraJSON (and falls back to thecidcolumn when it differs fromsession_id), so opening the B-leg also pulls in the A-leg; previously only A to B worked.status; operator-edited scripts are never touched.Tests
TestAppenderJSONColumnNotDoubleEncoded: writes through a real DuckDB Appender into a JSON column and assertsjson_type(data_extra) = 'OBJECT'plusx_call_idextraction (fails on the old code).TestSeedDefaultCorrelationScript_UpgradesLegacyTemplatefor the in-place seed upgrade.go testoverstorage/...,coordinator/...,scripting/...,lineprotoreceiver,decoder,writeris green;go vetclean.X-CID, transaction view returns bothsession_ids in both directions.Caveat for existing data
Rows ingested on 11.0.236-11.0.241 remain double-encoded on disk; the fix applies to new writes. They can age out with retention or be repaired once with:
Bumps
VERSION_APPLICATIONto 11.0.242.