Skip to content

Reproduction for sentry-python#8027 - #61

Open
sentry-junior[bot] wants to merge 1 commit into
mainfrom
repro/sentry-python-8027
Open

sentry-junior[bot] wants to merge 1 commit into
mainfrom
repro/sentry-python-8027

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 14, 2026

Copy link
Copy Markdown

Reproduction for getsentry/sentry-python#8027. That issue covers flaky Django cache span tests in streaming mode: test_cache_spans_item_size[True] and test_cache_spans_decorator[True].

What it shows
With trace_lifecycle="stream", each segment that finishes adds its trace to SpanBatcher._pending_flush, and that attribute is a set. If the flusher wakes after two segments have both finished, it sends them in hash order instead of the order they finished. The Django tests read spans by position across two requests, so request 2's cache hit can show up as spans[0].

Run it

cd sentry-python/8027
uv run --python 3.12 --with sentry-sdk==2.72.0 python repro.py --iterations 500                  # natural timing
uv run --python 3.12 --with sentry-sdk==2.72.0 python repro.py --iterations 500 --delay-flusher  # force the both-pending case

The script exits 1 with BUG REPRODUCED when the traces are sent out of order.

Local results (Python 3.12.15, sentry-sdk 2.72.0)

  • --delay-flusher: 146 of 300 iterations were out of order.
  • Natural timing, 5 runs of 200 iterations: 91, 104, 101, 99 and 95 out of order, about 49%.

via johdax.

--

View Junior Session [Sentry]

Co-Authored-By: Johannes Daxböck <johannes.daxboeck@sentry.io>
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.

0 participants