Skip to content

ci(backend): Bump backend test shards to 30 - #129077

Merged
joshuarli merged 4 commits into
masterfrom
ci/bump-backend-shards-30
Oct 28, 2026
Merged

joshuarli merged 4 commits into
masterfrom
ci/bump-backend-shards-30

Conversation

@joshuarli

@joshuarli joshuarli commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

i've spent some effort getting the per-shard overhead down as much as humanly possible

with that, i'm comfortable sharding out more now

backend shards 22 -> 30 gets us ~25% faster on the full suite

will followup with adjusting selective testing to rightsize


Increase backend test shards from 22 to 30 and fix the shard balance data.

  • .github/workflows/backend.yml static default shards 22 -> 30
  • .github/workflows/scripts/calculate-backend-test-shards.py MAX_SHARDS 22 -> 30
  • Refreshed backend-test-durations.json from the 30-shard colored full run (40755937953): old weights overestimated total test time 1.7x and missed new files, producing a 294-715s actual spread against 860s predictions.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 28, 2026
@joshuarli joshuarli added the Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling label Oct 28, 2026
@joshuarli
joshuarli marked this pull request as ready for review October 28, 2026 21:55
@joshuarli
joshuarli requested review from a team as code owners October 28, 2026 21:55
@joshuarli
joshuarli requested review from mchen-sentry and removed request for a team October 28, 2026 21:55
Increase MAX_SHARDS from 22 to 30 to reduce per-shard runtime on full backend runs.
Merge per-shard test-durations.json artifacts from run 40755937953 (all 30 shards green). Old weights overestimated total test time 1.7x (25551s vs 14887s actual) and missed files like test_pagination.py, producing a 294-715s actual spread against 860s predictions. Fresh weights balance to 504s predicted per general shard; shard 0 predicts 480s, exactly matching actual.
test_organization_agent_token.py held 1680 collected tests (runtime-generated matrix) and test_transactions_rebalancing.py 679 (module-global parametrize), each landing whole or striped across shards and wrecking balance. Split into per-theme files with identical collected totals (1680 = 30+15+1635, 679 = 504+168+6+1, verified by collect-only). Shared matrix/param infrastructure is imported from the kept originals, following existing cross-test import precedent. Seed durations for the new files by splitting the measured per-file seconds proportionally to collected tests, so the next full run plans balanced immediately.
@joshuarli
joshuarli force-pushed the ci/bump-backend-shards-30 branch from 74627af to a3fa088 Compare October 28, 2026 22:04

@mchen-sentry mchen-sentry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine, but can we explain why we're splitting the files when there's a planner that breaks them apart already?

@github-actions

Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on b1097f8 in this run:

tests/sentry/db/models/test_slug_concurrency.py::ConcurrentSlugTest::test_teams_get_different_slugs — log
[gw0] linux -- Python 3.13.17 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/db/models/test_slug_concurrency.py:119: in test_teams_get_different_slugs
    first, second = create_concurrently(
tests/sentry/db/models/test_slug_concurrency.py:77: in create_concurrently
    raise errors[0]
tests/sentry/db/models/test_slug_concurrency.py:63: in run_second
    results["second"] = create()
                        ^^^^^^^^
tests/sentry/db/models/test_slug_concurrency.py:121: in <lambda>
    lambda: Team.objects.create(organization=organization, name="Platform"),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/silo/base.py:157: in override
    return original_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/silo/base.py:157: in override
    return original_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/models/query.py:665: in create
    obj.save(force_insert=True, using=self.db)
src/sentry/silo/base.py:157: in override
    return original_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/sentry/models/team.py:156: in save
    self._save_team(
src/sentry/models/team.py:167: in _save_team
    save_with_snowflake_id(
src/sentry/utils/snowflake.py:59: in save_with_snowflake_id
    with enforce_constraints(transaction.atomic(using=router.db_for_write(type(instance)))):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.17/x64/lib/python3.13/contextlib.py:148: in __exit__
    next(self.gen)
src/sentry/db/postgres/transactions.py:115: in enforce_constraints
    with transaction:
         ^^^^^^^^^^^
src/sentry/testutils/hybrid_cloud.py:229: in new_atomic_exit
    maybe_flush_commit_hooks(connection)
src/sentry/testutils/hybrid_cloud.py:220: in maybe_flush_commit_hooks
    connection.run_and_clear_commit_hooks()
src/sentry/testutils/pytest/stale_database_reads.py:130: in run_and_clear_commit_hooks
    return old_run_and_clear_commit_hooks(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.venv/lib/python3.13/site-packages/django/db/backends/base/base.py:769: in run_and_clear_commit_hooks
    func()
src/sentry/hybridcloud/models/outbox.py:236: in _drain_shard_with_metrics
    self.drain_shard()
src/sentry/hybridcloud/models/outbox.py:424: in drain_shard
    in_test_assert_no_transaction(
... (3 more lines)

@joshuarli

Copy link
Copy Markdown
Member Author

Should be fine, but can we explain why we're splitting the files when there's a planner that breaks them apart already?

i've walked it back; it didn't make a difference and was cherry picked from an older experiment of mine

@joshuarli
joshuarli merged commit 31c5023 into master Oct 28, 2026
141 of 143 checks passed
@joshuarli
joshuarli deleted the ci/bump-backend-shards-30 branch October 28, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Trigger: Override Selective Testing Run the full test suite; necessary in cases where selected tests are flaky due to reshuffling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants