From 15aea8bcbc2dffa2bf9f3c8450b99bd072830028 Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Wed, 22 Jan 2025 10:43:34 +0100 Subject: [PATCH] make sure to pick the correct connection for raw deletes --- services/cleanup/cleanup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/cleanup/cleanup.py b/services/cleanup/cleanup.py index 763cd97c9..24a0ba1e5 100644 --- a/services/cleanup/cleanup.py +++ b/services/cleanup/cleanup.py @@ -28,6 +28,10 @@ def run_cleanup( with cleanup_context() as context: for model, query in models_to_cleanup: + # This is needed so that the correct connection is chosen for the + # `_raw_delete` queries, as otherwise it might chose a readonly connection. + query._for_write = True + manual_cleanup = MANUAL_CLEANUP.get(model) if manual_cleanup is not None: result = manual_cleanup(context, query)