Tracking: a retried event is stored twice, so revenue and count metrics double-count it

オープン
#1,543 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
活発
技術スタック
python

調査の方向性

Start with the event request schema in backend/app/schemas/tracking.py (around line 392), the events table in backend/app/models/event.py (lines 126-138), and the metric queries in AnalysisService.value_totals and event_counts in backend/app/services/analysis_service.py. The approach is not decided yet, so first get a maintainer decision on the event-id design. Done would mean a regression test that posts the same purchase twice to /track and shows revenue per user counts it once.

索引モデルが issue の本文から書いたものです。

説明

bug

What happens

POST /api/v1/tracking/track and POST /api/v1/tracking/batch store every event they receive, and nothing identifies an event across requests:

  • EventRequest (backend/app/schemas/tracking.py:392) has no event-id field;
  • events.id is generated by the server;
  • the events table has plain indexes only, with no unique constraint (backend/app/models/event.py:126-138).

So a client that retries after a timeout stores the event twice whenever the first request was in fact stored.

What it changes in results

  • Revenue metrics sum Event.value per user (AnalysisService.value_totals, backend/app/services/analysis_service.py:311), so a retried purchase counts twice.
  • Count metrics count every stored event (AnalysisService.event_counts, analysis_service.py:276), so they double too.
  • Conversion rates are unaffected, because they count distinct users.
  • Assignments are unaffected, because /assign is idempotent through the unique (experiment_id, user_id) index.

The error isn't the same in both arms. The arm whose clients retry more, for example a slower variant, gets more duplicates, which biases the comparison and doesn't just add noise.

Evidence

Read in the code at main d48e06c. It has not been reproduced by a run yet. The fix's regression test should do that: send the same purchase twice through /track, and check that revenue per user counts it once.

Direction (to be planned, not decided)

The usual pattern is an optional event id supplied by the client, deduplicated per user, in the manner of an idempotency key. That needs a migration, an API contract change and SDK changes, so it goes through the full process. It is also the first fault scenario for the ground-truth replay tests in #1544.

主要言語
Python
スター
0
フォーク
4
平均マージ
5時間 36分
マージ済み PR(30日)
509

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Controlvar/controlvar のほかの issue

Controlvar/controlvar の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。