Skip to content

fix(query): record a spilled query's filter segments in its sidecar - #911

Open
VfourTwenty wants to merge 1 commit into
Dynatrace:mainfrom
VfourTwenty:fix/830-spill-sidecar-segments
Open

VfourTwenty wants to merge 1 commit into
Dynatrace:mainfrom
VfourTwenty:fix/830-spill-sidecar-segments

Conversation

@VfourTwenty

Copy link
Copy Markdown
Contributor

Description

A spilled result's sidecar kept the query text but not the filter segments from --segment / --segments-file, so when the spill was gone or unreadable dtctl inspect told you to re-run a query that reads other rows

  • Added an optional segments field to SidecarManifest (id + variables, same shape as the query request's filterSegments and a --segments-file entry). it's omitempty, so a query without segments writes the same sidecar as before and old sidecars without the field still read fine
  • Both spill writers (buffered spill_write.go, streamed spill_stream_exec.go) now fill it from the executor's segments
  • inspect's spill_file_not_found / spill_file_unreadable advice adds them to the re-run command as -S 'id?var=a,b' flags. values are single-quoted, so pasting the command doesn't expand $ or backticks. if a value can't be written in -S syntax (e.g. it has a comma) it points at --segments-file instead and names the sidecar whose segments list can be used as that file

the issue says "names and variables", i went with the segment ids Grail actually received, since names given to -S are already resolved to UIDs by the time the executor runs and an id is an exact match while a name is a substring one. can switch if names make more sense)

Didn't touch inspect --list entries, the wrong-context advice or the sidecar of an inspect re-spill. + the query text in the same advice is still double-quoted like on main, could single-quote it in a follow-up

Related Issues

Closes #830

Testing

  • TestE2E_SpillSidecarRecordsTheSegmentsGrailReceived runs the executor against an httptest Grail on the buffered and the streamed spill path and checks the sidecar's segments equal the filterSegments in the request
  • TestInspectAdviceReRunsTheQueryWithItsSegments runs inspect on a spill whose data file is gone, passes the advised command through bash -c and feeds the -S values back through parseSegmentFlags. they have to give the recorded segments, including values with $, backticks, quotes, tab, newline and a no-break space (skipped on windows)
  • TestInspectAdviceNamesASegmentsFileWhenABindingCannotBeInline checks the --segments-file fallback and that the sidecar's list parses through parseSegmentsFile

all three fail on main. ran everything in docker on go 1.26.11

  • Tests pass (make test)
  • Linting passes (make lint)

@VfourTwenty
VfourTwenty requested review from a team and discostu105 as code owners December 6, 2026 11:15

This branch has not been deployed

No deployments
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.

The sidecar of a spilled result records the query text but not its filter segments

1 participant