fix(api): bound ansible backfill query cost
This commit is contained in:
@@ -43,6 +43,7 @@ async def _fetch_missing_candidate_incidents(
|
||||
scan_limit: int,
|
||||
) -> list[dict[str, Any]]:
|
||||
async with get_db_context(project_id) as db:
|
||||
await db.execute(text("SET LOCAL statement_timeout = '5000ms'"))
|
||||
result = await db.execute(
|
||||
text("""
|
||||
SELECT
|
||||
@@ -69,6 +70,7 @@ async def _fetch_missing_candidate_incidents(
|
||||
SELECT 1
|
||||
FROM automation_operation_log existing
|
||||
WHERE existing.operation_type = 'ansible_candidate_matched'
|
||||
AND existing.created_at >= NOW() - (:window_hours * INTERVAL '1 hour')
|
||||
AND existing.input ->> 'executor' = 'ansible'
|
||||
AND coalesce(existing.incident_id::text, existing.input ->> 'incident_id') = incidents.incident_id::text
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user