Skip to content

fix(experimentation): retry experiment computes on transient ClickHouse errors - #8273

Merged
Zaimwa9 merged 5 commits into
mainfrom
fix/experimentation-clickhouse-timeouts
Aug 13, 2026
Merged

fix(experimentation): retry experiment computes on transient ClickHouse errors#8273
Zaimwa9 merged 5 commits into
mainfrom
fix/experimentation-clickhouse-timeouts

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #8274

Experiment computes fail with TimeoutError when a ClickHouse read exceeds the 30s send_receive_timeout, and the failure was swallowed, so refreshes silently produced nothing.

  • Raise TaskBackoffError on OSError in compute_experiment_exposures/compute_experiment_results so the task processor retries.
  • Use a 120s timeout for background warehouse queries (interactive paths keep 30s), with a matching 3-minute task timeout. One client is cached per timeout.

How did you test this code?

Unit tests covering the retry behaviour, per-timeout client caching, and background timeout usage; full experimentation suite, lint, and mypy pass.

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 13, 2026 7:25am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ignored Ignored Preview Aug 13, 2026 7:25am
flagsmith-frontend-staging Ignored Ignored Preview Aug 13, 2026 7:25am

Request Review

@Zaimwa9
Zaimwa9 requested review from a team as code owners August 12, 2026 14:41
@Zaimwa9
Zaimwa9 requested review from khvn26 and removed request for a team August 12, 2026 14:41
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 002d4354-adf2-4e42-9f0e-62e92c6dfb1a

📥 Commits

Reviewing files that changed from the base of the PR and between 9948552 and 4b9ac1d.

📒 Files selected for processing (3)
  • api/experimentation/services.py
  • api/tests/unit/experimentation/test_services.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

📝 Walkthrough

Walkthrough

The change adds a 120-second timeout for background ClickHouse queries and caches clients by timeout variant. Exposure and metric-statistics queries use this timeout. Experiment computation tasks use a three-minute timeout and raise TaskBackoffError for OSError failures after recording and logging them. Tests cover client reuse, timeout propagation, transient failures, and timeout ordering. The event catalogue source references are updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to 4b9ac

The change adjusts retry handling and background query timeouts; the supplied evidence identifies no actionable merge-blocking correctness, availability, or deployment risk beyond normal checks.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates labels Aug 12, 2026
@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8273 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8273 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-8273 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8273 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-8273 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8273 Finished ✅ Results

@github-actions github-actions Bot added fix and removed docs Documentation updates labels Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 512e0bf4-0731-4580-b052-c50b33090bc0

📥 Commits

Reviewing files that changed from the base of the PR and between 6c88198 and 9dbb11a.

📒 Files selected for processing (6)
  • api/experimentation/services.py
  • api/experimentation/tasks.py
  • api/tests/unit/experimentation/test_services.py
  • api/tests/unit/experimentation/test_tasks.py
  • api/tests/unit/experimentation/test_views.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

Comment thread api/experimentation/services.py Outdated
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.75%. Comparing base (8aca57e) to head (4b9ac1d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8273   +/-   ##
=======================================
  Coverage   98.74%   98.75%           
=======================================
  Files        1569     1569           
  Lines       62778    62827   +49     
=======================================
+ Hits        61993    62042   +49     
  Misses        785      785           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19282 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  5 passed

Details

stats  5 tests across 4 suites
duration  40 seconds
commit  4b9ac1d
info  🔄 Run: #19282 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #19282 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.4 seconds
commit  4b9ac1d
info  🔄 Run: #19282 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19282 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  38.4 seconds
commit  4b9ac1d
info  🔄 Run: #19282 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19282 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  47 seconds
commit  4b9ac1d
info  🔄 Run: #19282 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19259 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  1 minute, 4 seconds
commit  9948552
info  🔄 Run: #19259 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19259 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  23 passed
skipped  1 skipped

Details

stats  24 tests across 18 suites
duration  1 minute, 27 seconds
commit  9948552
info  🔄 Run: #19259 (attempt 1)

Skipped tests

firefox › tests/onboarding-tests.pw.ts › Onboarding › New user connects via the single-page onboarding flow @oss

✅ oss · depot-ubuntu-latest-arm-16 — run #19259 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  46.9 seconds
commit  9948552
info  🔄 Run: #19259 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19259 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41 seconds
commit  9948552
info  🔄 Run: #19259 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #19251 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  4 passed

Details

stats  4 tests across 4 suites
duration  49.3 seconds
commit  ee6860f
info  🔄 Run: #19251 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #19251 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  43.1 seconds
commit  ee6860f
info  🔄 Run: #19251 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #19251 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  47.3 seconds
commit  ee6860f
info  🔄 Run: #19251 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #19251 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  23 passed
skipped  1 skipped

Details

stats  24 tests across 18 suites
duration  1 minute, 22 seconds
commit  ee6860f
info  🔄 Run: #19251 (attempt 1)

Skipped tests

firefox › tests/onboarding-tests.pw.ts › Onboarding › New user connects via the single-page onboarding flow @oss

@github-actions

Copy link
Copy Markdown
Contributor
✅ oss · depot-ubuntu-latest-16 — run #19249 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.9 seconds
commit  9dbb11a
info  🔄 Run: #19249 (attempt 1)

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@github-actions github-actions Bot added docs Documentation updates and removed fix docs Documentation updates labels Aug 12, 2026

@khvn26 khvn26 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.

Questions.

Comment thread api/experimentation/services.py Outdated
Comment thread api/experimentation/services.py Outdated
Comment thread api/experimentation/services.py
Comment thread api/experimentation/tasks.py Outdated
@khvn26 khvn26 self-assigned this Aug 12, 2026
@github-actions github-actions Bot added fix and removed fix docs Documentation updates labels Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/tests/unit/experimentation/test_services.py (1)

112-141: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Verify reuse of the background-timeout client.

The test calls _get_clickhouse_client with the background timeout only once. It proves default-client reuse and timeout-variant separation, but it does not prove reuse for repeated background calls. Add a second background call and assert that it returns the same client while mock_client_cls.call_count remains 2.

Proposed test adjustment
     background_client = services._get_clickhouse_client(
         send_receive_timeout=services.CLICKHOUSE_BACKGROUND_QUERY_TIMEOUT_SECONDS,
     )
+    same_background_client = services._get_clickhouse_client(
+        send_receive_timeout=services.CLICKHOUSE_BACKGROUND_QUERY_TIMEOUT_SECONDS,
+    )

     # Then
     assert client is same_client
     assert background_client is not client
+    assert same_background_client is background_client
     assert mock_client_cls.call_count == 2

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5ec8ac89-4610-43eb-8285-4d1461ace406

📥 Commits

Reviewing files that changed from the base of the PR and between 5e0bc97 and 9948552.

📒 Files selected for processing (3)
  • api/experimentation/services.py
  • api/tests/unit/experimentation/test_services.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

khvn26
khvn26 previously approved these changes Aug 12, 2026
…lickhouse-timeouts

# Conflicts:
#	docs/docs/deployment-self-hosting/observability/_events-catalogue.md
@github-actions github-actions Bot added the docs Documentation updates label Aug 13, 2026
@github-actions github-actions Bot added fix and removed fix docs Documentation updates labels Aug 13, 2026
@Zaimwa9
Zaimwa9 merged commit a62f3e5 into main Aug 13, 2026
35 checks passed
@Zaimwa9
Zaimwa9 deleted the fix/experimentation-clickhouse-timeouts branch August 13, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants