Commit gateway usage records and token-budget updates atomically
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 70/100
Research direction
Read record_usage in secondshift/gateway/metering.py and the DAO operations in secondshift/gateway/dao.py to trace the two writes and their async adapter. Add a test that makes the token increment fail after the usage insert; done means neither the usage record nor the budget update commits, while the F() increment remains in use.
Written by the indexing model from the issue text.
Description
Priority: Important
record_usage in secondshift/gateway/metering.py awaits separate writes to ModelUsage and RunToken.used_tokens in secondshift/gateway/dao.py. If the second write fails or the task is cancelled between writes, the usage row can remain committed while the budget counter stays unchanged. Future requests check the counter and can continue with a stale balance.
Execute the two writes in one synchronous transaction.atomic() DAO operation called through the async adapter, retaining the F() increment for concurrent requests. Add a test that forces the increment to fail after the insert and verifies that neither change commits.
Opened by SecondShift from run #279 at ef292eae0f91.
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- Avg merge
- 1h 9m
- Merged PRs (30d)
- 322
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from piotrekno1/second-shift
-
code-review secondshift
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
piotrekno1/second-shift#419 ·
Maintainers usually reply within 1 day
-
area: deployment
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
piotrekno1/second-shift#310 ·
Maintainers usually reply within 1 day
-
code-review secondshift
Difficulty 4/5 3-5 days Newbie friendliness 46/100
piotrekno1/second-shift#421 ·
Maintainers usually reply within 1 day
-
code-review secondshift
Difficulty 4/5 3-5 days Newbie friendliness 56/100
piotrekno1/second-shift#420 ·
Maintainers usually reply within 1 day
-
Fix failed-delivery retries on PostgreSQLPossibly taken @piotrekno1 claimed this today. Opencode-review fix-approved secondshift
Difficulty 3/5 1-2 days Newbie friendliness 35/100
piotrekno1/second-shift#418 ·
Maintainers usually reply within 1 day
All issues in piotrekno1/second-shift
Similar issues
-
needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
flashinfer-ai/flashinfer#9803 ·
Maintainers usually reply within 1 day
-
bug frontend good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oscarbol09/thesisforge#61 ·
-
api bug performance
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
oscarbol09/audiobard#159 ·
-
area:web p2 product:business triage:active type:bug
Difficulty 1/5 Under an hour Newbie friendliness 89/100
cuadrao-ai/argus#2328 ·
Maintainers usually reply within 1 day
-
bug frontend good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
nikhilb2/simple_invoicing#907 ·