Private
Public Access
Route every feed fetch through one atomic claim (R2-T1, #32)
Adding a feed and the admin retry queued fetch_feed directly without claiming the feed, so the periodic poller (which sees a never-fetched or just-reset feed as due) could claim and fetch it too: duplicate fetches, and one task overwriting another's claim/ETag/next-fetch state. The retry path also queued the backoff reset and the fetch as two independent tasks that could run in either order. claim_feed/enqueue_fetch in apps.feeds.tasks are now the only way a fetch gets dispatched — the poller, add-feed and retry all use them, so a feed can only have one fetch in flight. If queueing fails the claim is released (the poller recovers it), and add-feed still saves the subscription during a broker outage. The retry resets backoff synchronously before claiming, and says so when a fetch is already running. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0975a7634b
commit
85914f9107
5 files changed
+184
-33
No files matched your search
+9
-4
@@ -10,7 +10,7 @@ from django.views.decorators.http import require_POST
|
||||
|
||||
from apps.articles.models import Article
|
||||
from apps.feeds.models import Feed, Subscription
|
||||
from apps.feeds.tasks import POLL_HEARTBEAT_CACHE_KEY, fetch_feed, reset_feed_backoff
|
||||
from apps.feeds.tasks import POLL_HEARTBEAT_CACHE_KEY, enqueue_fetch, reset_backoff
|
||||
|
||||
from .health import fetch_pipeline_status
|
||||
|
||||
@@ -108,7 +108,12 @@ def dashboard(request):
|
||||
@require_POST
|
||||
def retry_feed(request, feed_id):
|
||||
feed = get_object_or_404(Feed, pk=feed_id)
|
||||
reset_feed_backoff.delay(feed.id)
|
||||
fetch_feed.delay(feed.id)
|
||||
messages.success(request, f"Queued an immediate retry for '{feed.title or feed.feed_url}'.")
|
||||
# Reset first, synchronously: as separate queued tasks the reset could
|
||||
# land after the fetch and undo the schedule it just set.
|
||||
reset_backoff(feed.id)
|
||||
name = feed.title or feed.feed_url
|
||||
if enqueue_fetch(feed.id):
|
||||
messages.success(request, f"Queued an immediate retry for '{name}'.")
|
||||
else:
|
||||
messages.info(request, f"'{name}' is already being fetched right now.")
|
||||
return redirect("core:dashboard")
|
||||
Reference in new issue
Block a user