Title: Flaky Django cache span tests in streaming mode · Issue #8027 · getsentry/sentry-python · GitHub
Open Graph Title: Flaky Django cache span tests in streaming mode · Issue #8027 · getsentry/sentry-python
X Title: Flaky Django cache span tests in streaming mode · Issue #8027 · getsentry/sentry-python
Description: tests/integrations/django/test_cache_module.py::test_cache_spans_item_size[True] and ::test_cache_spans_decorator[True] fail intermittently on master in streaming mode (span_streaming=True). Both tests make two requests, one trace each, ...
Open Graph Description: tests/integrations/django/test_cache_module.py::test_cache_spans_item_size[True] and ::test_cache_spans_decorator[True] fail intermittently on master in streaming mode (span_streaming=True). Both t...
X Description: tests/integrations/django/test_cache_module.py::test_cache_spans_item_size[True] and ::test_cache_spans_decorator[True] fail intermittently on master in streaming mode (span_streaming=True). Both t...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/8027
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Flaky Django cache span tests in streaming mode","articleBody":"`tests/integrations/django/test_cache_module.py::test_cache_spans_item_size[True]` and `::test_cache_spans_decorator[True]` fail intermittently on master in streaming mode (`span_streaming=True`). Both tests make two requests, one trace each, and index the captured spans by position. Sometimes request 2's spans arrive first.\n\n**Failure**\n```\ntests/integrations/django/test_cache_module.py:763: in test_cache_spans_item_size\n assert not spans[0][\"attributes\"][\"cache.hit\"]\nE assert not True\n```\n`test_cache_spans_decorator[True]` fails the same way at line 384.\n\n**Expected vs actual**\n- Expected: `spans[0]` is request 1's `cache.get`, a miss.\n- Actual: `spans[0]` is request 2's `cache.get`, a hit. `len(spans) == 7` still passes; only the order across the two traces changes.\n\n**CI failures on master (Sep 30 – Oct 13, 6 of 33 `Test` runs)**\n- `test_cache_spans_item_size[True]`: py3.14 django-v6.1.2, `916942d` ([job](https://github.com/getsentry/sentry-python/actions/runs/38401183446/job/115308926910)); py3.14 django-v6.1.1, `b5737a0` ([job](https://github.com/getsentry/sentry-python/actions/runs/37482438288/job/112333779485)); py3.14 django-v6.1.1, `8afefe8` ([job](https://github.com/getsentry/sentry-python/actions/runs/36872457774/job/110403408859))\n- `test_cache_spans_decorator[True]`: py3.12 django-v4.2.30, `6a4eb20` ([job](https://github.com/getsentry/sentry-python/actions/runs/37353417938/job/111909675607)); py3.14 django-v5.2.17, `bf1e2f9` ([job](https://github.com/getsentry/sentry-python/actions/runs/36718657588/job/109897836977)); py3.10 django-v5.2.17, `8012047` ([job](https://github.com/getsentry/sentry-python/actions/runs/36712378716/job/109877001736))\n- Always the `Web 1` job, always `[True]` (streaming). It appears on Django 4.2 through 6.1 and Python 3.10 through 3.14.\n\n**Known trigger**\n- In streaming mode, each finished segment adds its `trace_id` to `SpanBatcher._pending_flush`, which is a `set` (`sentry_sdk/_span_batcher.py`). Pending flushing was added in #7170.\n- If the background flusher wakes only after both requests' segments have finished, `list(self._pending_flush)` sends the two traces in set (hash) order instead of the order they finished. That happens about 50% of the time once both are pending.\n- On an idle machine the flusher usually sends request 1 before request 2 ends. A busy CI runner delays the flusher thread, so both end up pending.\n- #7444 (uuid `LOCATION` for the cache) fixed a different flake in these tests. These failures all happened after it was merged.\n\n\u003c!-- junior-request-attribution:start -->\nvia **johdax**.\n\u003c!-- junior-request-attribution:end -->\n\n\u003c!-- junior-session-footer:start -->\n\u003c!-- junior-conversation-id:agent-dispatch%3Adispatch_6df7374375b237816e130534b6439833 -->\n\n--\n\n[View Junior Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_6df7374375b237816e130534b6439833) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_6df7374375b237816e130534b6439833/?project=4510944073809921)\n\n\u003c!-- junior-session-footer:end -->","author":{"url":"https://github.com/apps/sentry-junior","@type":"Person","name":"sentry-junior"},"datePublished":"2026-10-14T09:22:40Z","url":"https://github.com/getsentry/sentry-python/issues/8027"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8f10b35b-f879-330f-bc44-b851416b25bb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D860:7A60E:CB1617:107231F:6B00F2DD |
| html-safe-nonce | a677701d8a626e34fa55bb0d6f4d1e300403fc4382c7f63b5fb920ccff1f3466 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODYwOjdBNjBFOkNCMTYxNzoxMDcyMzFGOjZCMDBGMkREIiwidmlzaXRvcl9pZCI6IjQwOTgwMzM2NDEyOTUyNDYwNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a2d555b9d3191d09d6f086c2f702a4393690546688b4eb559af7907ecceb063e |
| hovercard-subject-tag | issue:5845247890 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-python/8027/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b318e95171717e1f5c60e361781cb292bd005d1bf46302354eb33428890e53d5/getsentry/sentry-python/issues/8027 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b318e95171717e1f5c60e361781cb292bd005d1bf46302354eb33428890e53d5/getsentry/sentry-python/issues/8027 |
| og:image:alt | tests/integrations/django/test_cache_module.py::test_cache_spans_item_size[True] and ::test_cache_spans_decorator[True] fail intermittently on master in streaming mode (span_streaming=True). Both t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sentry-junior[bot] |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width