You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CodeRabbit's review of #1170 raised two hardening suggestions for FirestoreStateService.cleanup_old_states() that are correct in principle but
sit outside the scope of that PR, which was a pure latency change. Filing them
here so they are not lost.
1. Make CLEANUP_DELETE_CONCURRENCY environment-configurable
src/youtube_extension/services/cloud/firestore_state.py currently hardcodes:
CLEANUP_DELETE_CONCURRENCY=16
Suggestion was int(os.getenv("CLEANUP_DELETE_CONCURRENCY", "16")).
Deferred because:
The equivalent constant merged in ad7e2c1 (TAG_WRITE_CONCURRENCY = 8 in intelligent_cache.py) is also a plain module constant. Making only this one
configurable is inconsistent.
A bare int(os.getenv(...)) raises ValueError at import time on a
malformed value, turning a typo into an unimportable module. It needs a
validating parse with a fallback, which is its own change with its own tests.
If this is done, do both constants together behind one shared helper.
2. Pass an explicit timeout to doc.reference.delete()
Suggestion was to bound each delete with a deadline so a hung RPC cannot occupy
a pool worker indefinitely.
Deferred because:
There is no existing timeout constant in the module (grep -n 'timeout\|TIMEOUT'
returns nothing), so this means inventing a deadline policy rather than reusing one.
Any value chosen would sit on top of the Firestore async client's own retry and
deadline configuration; picking one without knowing that baseline risks
converting slow-but-successful deletes into tallied failures.
The right fix is probably a module-level deadline derived from the client config,
applied consistently to all Firestore calls in the service, not just cleanup.
Acceptance criteria
Concurrency constants parsed from env with validation and a safe fallback, applied to both firestore_state.py and intelligent_cache.py
A documented timeout policy for Firestore RPCs in firestore_state.py, with tests covering the timeout-as-failure path
No behaviour change when the env vars are unset
Scope
src/youtube_extension/services/cloud/firestore_state.py, src/youtube_extension/backend/services/intelligent_cache.py, and their unit tests.
Problem
CodeRabbit's review of #1170 raised two hardening suggestions for
FirestoreStateService.cleanup_old_states()that are correct in principle butsit outside the scope of that PR, which was a pure latency change. Filing them
here so they are not lost.
1. Make
CLEANUP_DELETE_CONCURRENCYenvironment-configurablesrc/youtube_extension/services/cloud/firestore_state.pycurrently hardcodes:Suggestion was
int(os.getenv("CLEANUP_DELETE_CONCURRENCY", "16")).Deferred because:
ad7e2c1(TAG_WRITE_CONCURRENCY = 8inintelligent_cache.py) is also a plain module constant. Making only this oneconfigurable is inconsistent.
int(os.getenv(...))raisesValueErrorat import time on amalformed value, turning a typo into an unimportable module. It needs a
validating parse with a fallback, which is its own change with its own tests.
If this is done, do both constants together behind one shared helper.
2. Pass an explicit timeout to
doc.reference.delete()Suggestion was to bound each delete with a deadline so a hung RPC cannot occupy
a pool worker indefinitely.
Deferred because:
grep -n 'timeout\|TIMEOUT'returns nothing), so this means inventing a deadline policy rather than reusing one.
deadline configuration; picking one without knowing that baseline risks
converting slow-but-successful deletes into tallied failures.
regression introduced by perf: delete expired Firestore states concurrently under a bound #1170.
The right fix is probably a module-level deadline derived from the client config,
applied consistently to all Firestore calls in the service, not just cleanup.
Acceptance criteria
firestore_state.pyandintelligent_cache.pyfirestore_state.py, with tests covering the timeout-as-failure pathScope
src/youtube_extension/services/cloud/firestore_state.py,src/youtube_extension/backend/services/intelligent_cache.py, and their unit tests.