Fix clear-data to actually delete run_cache entries
- discard_run now deletes from run_cache and pending_runs tables - Add delete_run_cache() and delete_pending_run() database functions - Previously clear-data only cleared Redis, leaving DB cache intact Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -482,8 +482,18 @@ class RunService:
|
|||||||
# Remove task_id mapping from Redis
|
# Remove task_id mapping from Redis
|
||||||
self.redis.delete(f"{self.task_key_prefix}{run_id}")
|
self.redis.delete(f"{self.task_key_prefix}{run_id}")
|
||||||
|
|
||||||
# Note: We don't delete from run_cache as that's a permanent record
|
# Remove from run_cache database table
|
||||||
# of completed work. The content itself remains in cache.
|
try:
|
||||||
|
await self.db.delete_run_cache(run_id)
|
||||||
|
except Exception as e:
|
||||||
|
import logging
|
||||||
|
logging.getLogger(__name__).warning(f"Failed to delete run_cache for {run_id}: {e}")
|
||||||
|
|
||||||
|
# Remove pending run if exists
|
||||||
|
try:
|
||||||
|
await self.db.delete_pending_run(run_id)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
|
|||||||
20
database.py
20
database.py
@@ -1207,6 +1207,26 @@ async def list_runs_by_actor(actor_id: str, offset: int = 0, limit: int = 20) ->
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def delete_run_cache(run_id: str) -> bool:
|
||||||
|
"""Delete a run from the cache."""
|
||||||
|
async with pool.acquire() as conn:
|
||||||
|
result = await conn.execute(
|
||||||
|
"DELETE FROM run_cache WHERE run_id = $1",
|
||||||
|
run_id
|
||||||
|
)
|
||||||
|
return result == "DELETE 1"
|
||||||
|
|
||||||
|
|
||||||
|
async def delete_pending_run(run_id: str) -> bool:
|
||||||
|
"""Delete a pending run."""
|
||||||
|
async with pool.acquire() as conn:
|
||||||
|
result = await conn.execute(
|
||||||
|
"DELETE FROM pending_runs WHERE run_id = $1",
|
||||||
|
run_id
|
||||||
|
)
|
||||||
|
return result == "DELETE 1"
|
||||||
|
|
||||||
|
|
||||||
# ============ Storage Backends ============
|
# ============ Storage Backends ============
|
||||||
|
|
||||||
async def get_user_storage(actor_id: str) -> List[dict]:
|
async def get_user_storage(actor_id: str) -> List[dict]:
|
||||||
|
|||||||
Reference in New Issue
Block a user