Skip to content

Fix: Replace firebase PENDING gate with version-based idempotency#267

Open
susilnem wants to merge 1 commit into
developfrom
fix/race-condition-push-to-firebase
Open

Fix: Replace firebase PENDING gate with version-based idempotency#267
susilnem wants to merge 1 commit into
developfrom
fix/race-condition-push-to-firebase

Conversation

@susilnem

@susilnem susilnem commented Jul 1, 2026

Copy link
Copy Markdown
Member

The PENDING status guard caused a race: a stats push (only_stats=True) and a status-change push racing for the same project would leave the second push rejected as FAILED, keeping a FINISHED project visible in Firebase.

Problem

When a stats push (only_stats=True) and a status-change push raced for the
same project, the second push hit the PENDING guard and was rejected as FAILED,
leaving a FINISHED project still visible in Firebase.

Changes

Replaced the PENDING status gate with two version counters on Project:

  • firebase_push_requested_version — bumped atomically by every push trigger
  • firebase_pushed_version — recorded on success using the snapshot taken at
    task start (not a re-read), so a concurrent bump can't be marked as satisfied
    with stale data

The push task:

  1. Skips if pushed_version >= requested_version (already up-to-date, no false FAILED)
  2. Re-enqueues on success if requested_version grew mid-push — heals the silent
    lock-drop path where a concurrent task is dropped while the lock is held

This PR doesn't introduce any:

  • temporary files, auto-generated files or secret keys
  • n+1 queries
  • flake8 issues
  • print
  • typos
  • unwanted comments

This PR contains valid:

  • tests
  • permission checks (tests here too)
  • translations

…tency

The PENDING status guard caused a race: a stats push (only_stats=True) and a
status-change push racing for the same project would leave the second push
rejected as FAILED, keeping a FINISHED project visible in Firebase.
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.68%. Comparing base (189901a) to head (e987cfa).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #267      +/-   ##
===========================================
+ Coverage    87.55%   87.68%   +0.13%     
===========================================
  Files          211      212       +1     
  Lines        12819    12907      +88     
  Branches      1089     1090       +1     
===========================================
+ Hits         11224    11318      +94     
+ Misses        1196     1192       -4     
+ Partials       399      397       -2     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant