Experimentation: completing an experiment does not compute final results, while the docs say they are frozen as final

Open
#9,129 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
67/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, python
Domain
analytics, backend

Research direction

Trace the experiment completion endpoint and the results refresh endpoint described in the reproduction, then read the “Analyse an experiment” documentation page. Check what triggers the final results computation and how the five-minute refresh limit affects it. Done means completion makes results final without waiting for a later refresh, or the documentation and results page explain when that refresh is available.

Written by the indexing model from the issue text.

Description

Describe the bug

After POST .../experiments/{id}/complete/, the results endpoint keeps returning the last snapshot from before completion, with is_final: false. Final results appear only after the next results refresh, which is still subject to the 5-minute limit counted from the last refresh before completion, and only if something requests it.

The "Analyse an experiment" page says that after ending an experiment "Results are frozen as final and the flag is unlocked." A user who ends an experiment and reads the results page straight away sees a non-final snapshot, and nothing finalises it unless they come back and refresh.

Observed on self-hosted v2.295.2 (CI_COMMIT_SHA 5369ece3ff3aefbd021d2496f82a7ce0e9cd04d6), Postgres warehouse.

Steps To Reproduce
  1. Create a multivariate flag (control plus blue, green), a metric and an experiment, start it, and send exposures for 300 identities with the Python SDK.
  2. POST .../results/refresh/ and read GET .../results/: is_final: false, with an as_of.
  3. POST .../complete/ with {"rollout_decision": "variant", "rollout_variant": <blue option id>}. ended_at is set.
  4. Read GET .../results/ 5 s and 60 s later, with no refresh requested: same as_of as in step 2, is_final: false.
  5. POST .../results/refresh/ straight away: HTTP 429, {"detail":"A refresh was requested recently. Try again later. Expected available in 239 seconds."}.
  6. After the limit, POST .../results/refresh/: the results now read is_final: true.
  7. A further refresh: HTTP 400, {"detail":"Results are final for this completed experiment."}.
Expected behavior

Either completing queues the final computation (so the results become final shortly after completion without another request, regardless of the refresh limit), or the docs and the results page say that final results need one more refresh after ending the experiment, and when it will be allowed.

How are you running Flagsmith
  • Self-hosted with Docker
Dominant language
Python
Stars
9.9k
Forks
658
Avg merge
1d 15h
Merged PRs (30d)
168

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Flagsmith/flagsmith

All issues in Flagsmith/flagsmith

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.