From e3afe9d7c73298d7b1b3f2321803c6698641571b Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 10 Jun 2026 00:10:52 +0200 Subject: [PATCH] fix(luma): commit failed status immediately --- .../app/tasks/connector_indexers/luma_indexer.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/surfsense_backend/app/tasks/connector_indexers/luma_indexer.py b/surfsense_backend/app/tasks/connector_indexers/luma_indexer.py index 9bcba5a37..eab2c9793 100644 --- a/surfsense_backend/app/tasks/connector_indexers/luma_indexer.py +++ b/surfsense_backend/app/tasks/connector_indexers/luma_indexer.py @@ -7,6 +7,7 @@ Implements 2-phase document status updates for real-time UI feedback: """ import asyncio +import contextlib import time from collections.abc import Awaitable, Callable from datetime import datetime, timedelta @@ -485,10 +486,15 @@ async def index_luma_events( try: document.status = DocumentStatus.failed(str(e)) document.updated_at = get_current_timestamp() + # Commit now so the failed status survives a later rollback or + # crash; otherwise the doc stays stuck in pending/processing. + await session.commit() except Exception as status_error: logger.error( f"Failed to update document status to failed: {status_error}" ) + with contextlib.suppress(Exception): + await session.rollback() skipped_events.append( f"{item.get('event_name', 'Unknown')} (processing error)" )