Celery deduplication guard#121
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a Redis-based distributed lock to prevent concurrent executions of ChangesRedis task deduplication lock
CI and Dependabot configuration
Sequence Diagram(s)sequenceDiagram
participant Caller
participant redis_task_lock
participant build_add_or_update_lock_key
participant Redis
participant boost_add_or_update_task
Caller->>redis_task_lock: invoke(**kwargs)
redis_task_lock->>build_add_or_update_lock_key: compute key from sorted/hashed kwargs
build_add_or_update_lock_key-->>redis_task_lock: "boost_weblate:add_or_update:<digest>"
redis_task_lock->>Redis: Lock.acquire(blocking=wait|False)
alt acquired
Redis-->>redis_task_lock: True
redis_task_lock->>boost_add_or_update_task: call wrapped function
boost_add_or_update_task-->>redis_task_lock: result
redis_task_lock->>Redis: lock.release()
redis_task_lock-->>Caller: result
else not acquired
Redis-->>redis_task_lock: False
redis_task_lock-->>Caller: raise BoostEndpointError(TASK_DUPLICATE, lock_key=...)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/boost_weblate/settings_override.py`:
- Around line 151-154: The `BOOST_TASK_LOCK_ON_CONFLICT` environment variable
value is being used directly without validation or normalization, which can
cause silent behavior changes if the value has different casing (like "WAIT") or
whitespace. Normalize the environment variable value by converting it to
lowercase and stripping whitespace before assigning it to the `on_conflict` key
in the settings dictionary at lines 151-154. This ensures the value matches the
exact string check (like "wait") performed in
src/boost_weblate/utils/task_lock.py at line 86.
In `@src/boost_weblate/utils/task_lock.py`:
- Around line 105-108: The `lock.release()` call in the `finally` block only
catches `LockError`, but redis-py's Lock.release() can raise other exceptions
like `ConnectionError`, `TimeoutError`, and other `RedisError` subclasses that
aren't subclasses of LockError. When these infrastructure errors occur after
successful task execution, they cause the task to fail despite success. Replace
the single except clause with two separate exception handlers: catch `LockError`
first (which includes LockNotOwnedError as a subclass) with debug logging, then
catch `RedisError` with warning logging. This way lock-specific errors are
handled differently from Redis infrastructure errors, preventing false task
failures that trigger duplicate reprocessing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f43343bd-ba1f-406d-aca9-5ec47b57bda9
📒 Files selected for processing (7)
.github/dependabot.yml.github/workflows/weblate-pin-bump.ymlsrc/boost_weblate/endpoint/errors.pysrc/boost_weblate/endpoint/tasks.pysrc/boost_weblate/settings_override.pysrc/boost_weblate/utils/task_lock.pytests/endpoint/test_views.py
henry0816191
left a comment
There was a problem hiding this comment.
- Update boost-endpoint-api.md for BoostEndpointErrorCode.TASK_DUPLICATE
Close #114.
Summary by CodeRabbit
Improvements
Testing
Chores
uvupdates to direct dependencies only..env.examplewith the new task-lock configuration options.