fix(spans): scope GetSpansByRunIDsAndName self-join to same run_id - #1
Draft
ndholaria-stripe wants to merge 1 commit into
Draft
fix(spans): scope GetSpansByRunIDsAndName self-join to same run_id#1ndholaria-stripe wants to merge 1 commit into
ndholaria-stripe wants to merge 1 commit into
Conversation
dynamic_span_id is derived from function/step identity and is reused across all runs of the same function. Joining spans only on dynamic_span_id caused a single run-data load to aggregate spans from every unrelated run sharing that ID, scanning millions of rows and taking 30+ seconds in production. Adding AND m.run_id = s.run_id to the join constrains s to spans belonging to the requested runs only. Follow-up/update rows (the reason the self-join exists) share both dynamic_span_id and run_id with their originating span, so the semantics of merging in post-emit attribute updates are preserved. Fixes inngest#4656 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
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.
Summary
dynamic_span_idis deterministic (derived from function/step identity) and is reused across all runs of the same functionGetSpansByRunIDsAndNamewas joining ondynamic_span_idalone, causing a single run-data load to scan spans from every unrelated run sharing that IDAND m.run_id = s.run_idto the JOIN condition to scope results to the requested runs onlydynamic_spanandrun_idwith their originating span, so post-emit attribute merge semantics are preservedReported impact: 30+ second queries scanning 2.4M rows for a single run load (57,775 distinct runs sharing one
dynamic_span_id).Fixes inngest#4656
Test plan
Release note
Fixed a performance bug where loading run trace data performed a cross-run self-join on
spans, causing queries to scan millions of rows from unrelated runs that happened to share the same deterministicdynamic_span_id.Migration note
None