Fix: Database-locked-Fehler beim Löschen von Lagen behoben
- PRAGMA busy_timeout=5000 in get_db() hinzugefügt (SQLite wartet bis zu 5s auf Lock-Freigabe) - Try/except im Delete-Endpoint: gibt HTTP 409 statt 500 bei Lock-Konflikt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dieser Commit ist enthalten in:
@@ -226,6 +226,7 @@ async def get_db() -> aiosqlite.Connection:
|
|||||||
db.row_factory = aiosqlite.Row
|
db.row_factory = aiosqlite.Row
|
||||||
await db.execute("PRAGMA journal_mode=WAL")
|
await db.execute("PRAGMA journal_mode=WAL")
|
||||||
await db.execute("PRAGMA foreign_keys=ON")
|
await db.execute("PRAGMA foreign_keys=ON")
|
||||||
|
await db.execute("PRAGMA busy_timeout=5000")
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -218,8 +218,16 @@ async def delete_incident(
|
|||||||
detail="Nur der Ersteller kann diese Lage loeschen",
|
detail="Nur der Ersteller kann diese Lage loeschen",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
await db.execute("DELETE FROM incidents WHERE id = ?", (incident_id,))
|
await db.execute("DELETE FROM incidents WHERE id = ?", (incident_id,))
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
except Exception as e:
|
||||||
|
if "database is locked" in str(e):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_409_CONFLICT,
|
||||||
|
detail="Datenbank ist momentan beschaeftigt. Bitte in wenigen Sekunden erneut versuchen.",
|
||||||
|
)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{incident_id}/articles")
|
@router.get("/{incident_id}/articles")
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren