|
1 | 1 | From f721dcadf3fd422743f7ee83b5e36ef8ca6fd197 Mon Sep 17 00:00:00 2001 |
2 | 2 | From: Dennis Kliban <dkliban@redhat.com> |
3 | 3 | Date: Tue, 25 Nov 2025 11:06:48 -0500 |
4 | | -Subject: [PATCH 1/6] Adds use of NewPulpcoreWorker from pulp_service. |
| 4 | +Subject: [PATCH 1/8] Adds use of NewPulpcoreWorker from pulp_service. |
5 | 5 |
|
6 | 6 | This also adds Redis based locking for tasks and resources. |
7 | 7 | --- |
@@ -570,7 +570,7 @@ index c187bd919..3ef86ba19 100644 |
570 | 570 | From 6ac2f55c2aae9ee53da0d5f4cac4384bff84feb7 Mon Sep 17 00:00:00 2001 |
571 | 571 | From: Dennis Kliban <dkliban@redhat.com> |
572 | 572 | Date: Fri, 12 Dec 2025 21:27:32 -0500 |
573 | | -Subject: [PATCH 2/6] fix releasing of locks for immediate tasks |
| 573 | +Subject: [PATCH 2/8] fix releasing of locks for immediate tasks |
574 | 574 |
|
575 | 575 | --- |
576 | 576 | pulpcore/tasking/tasks.py | 94 ++++++++++++++++++++++++++++++++++++--- |
@@ -727,7 +727,7 @@ index 3ef86ba19..6b7466980 100644 |
727 | 727 | From e70783f2bc64a99dda25c829ff133a0d059585e2 Mon Sep 17 00:00:00 2001 |
728 | 728 | From: Dennis Kliban <dkliban@redhat.com> |
729 | 729 | Date: Fri, 12 Dec 2025 21:51:11 -0500 |
730 | | -Subject: [PATCH 3/6] Release locks in execute task |
| 730 | +Subject: [PATCH 3/8] Release locks in execute task |
731 | 731 |
|
732 | 732 | --- |
733 | 733 | pulpcore/tasking/tasks.py | 66 ++++++++++++--------------------------- |
@@ -828,7 +828,7 @@ index 6b7466980..9e9e6f6d7 100644 |
828 | 828 | From 75f249190eeef4acbae366bb2b5392d01643e41a Mon Sep 17 00:00:00 2001 |
829 | 829 | From: Dennis Kliban <dkliban@redhat.com> |
830 | 830 | Date: Sat, 13 Dec 2025 05:46:49 -0500 |
831 | | -Subject: [PATCH 4/6] Make sure locks are released even if exceptions occur |
| 831 | +Subject: [PATCH 4/8] Make sure locks are released even if exceptions occur |
832 | 832 | outside of execute_task. |
833 | 833 |
|
834 | 834 | --- |
@@ -932,7 +932,7 @@ index 9e9e6f6d7..2d854099c 100644 |
932 | 932 | From ab0cd196500334388f63087714bdb6b235ef7c50 Mon Sep 17 00:00:00 2001 |
933 | 933 | From: Dennis Kliban <dkliban@redhat.com> |
934 | 934 | Date: Fri, 19 Dec 2025 14:26:52 -0500 |
935 | | -Subject: [PATCH 5/6] API workers acquire Task lock before executing task |
| 935 | +Subject: [PATCH 5/8] API workers acquire Task lock before executing task |
936 | 936 |
|
937 | 937 | --- |
938 | 938 | pulpcore/tasking/tasks.py | 142 +++++++++++++++++++++++++++----------- |
@@ -1113,7 +1113,7 @@ index 2d854099c..3e7ee72d6 100644 |
1113 | 1113 | From 5b024ec6e69c53ca897b2697507c0af1b1b70c83 Mon Sep 17 00:00:00 2001 |
1114 | 1114 | From: Dennis Kliban <dkliban@redhat.com> |
1115 | 1115 | Date: Fri, 19 Dec 2025 14:59:28 -0500 |
1116 | | -Subject: [PATCH 6/6] Improve logging for resource lock release |
| 1116 | +Subject: [PATCH 6/8] Improve logging for resource lock release |
1117 | 1117 |
|
1118 | 1118 | --- |
1119 | 1119 | pulpcore/tasking/tasks.py | 10 +++++++--- |
@@ -1169,3 +1169,94 @@ index 3e7ee72d6..a9e5c4885 100644 |
1169 | 1169 | -- |
1170 | 1170 | 2.52.0 |
1171 | 1171 |
|
| 1172 | + |
| 1173 | +From d384eecf3d640cfb800a8aa7a80f1847b0d87ac1 Mon Sep 17 00:00:00 2001 |
| 1174 | +From: Dennis Kliban <dkliban@redhat.com> |
| 1175 | +Date: Fri, 19 Dec 2025 21:23:28 -0500 |
| 1176 | +Subject: [PATCH 7/8] Revert the set_guid() in immediate tasks |
| 1177 | + |
| 1178 | +--- |
| 1179 | + pulpcore/tasking/tasks.py | 6 +----- |
| 1180 | + 1 file changed, 1 insertion(+), 5 deletions(-) |
| 1181 | + |
| 1182 | +diff --git a/pulpcore/tasking/tasks.py b/pulpcore/tasking/tasks.py |
| 1183 | +index a9e5c4885..23a3641ad 100644 |
| 1184 | +--- a/pulpcore/tasking/tasks.py |
| 1185 | ++++ b/pulpcore/tasking/tasks.py |
| 1186 | +@@ -14,7 +14,7 @@ from asgiref.sync import sync_to_async, async_to_sync |
| 1187 | + from django.conf import settings |
| 1188 | + from django.db import connection |
| 1189 | + from django.db.models import Model |
| 1190 | +-from django_guid import get_guid, set_guid |
| 1191 | ++from django_guid import get_guid |
| 1192 | + from pulpcore.app.apps import MODULE_PLUGIN_VERSIONS |
| 1193 | + from pulpcore.app.models import Task, TaskGroup, AppStatus |
| 1194 | + from pulpcore.app.redis_connection import get_redis_connection |
| 1195 | +@@ -104,8 +104,6 @@ def _execute_task(task): |
| 1196 | + return result |
| 1197 | + return None |
| 1198 | + finally: |
| 1199 | +- # Restore the task's GUID for proper logging (contexts.py bug workaround) |
| 1200 | +- set_guid(task.logging_cid) |
| 1201 | + # Release Redis locks if this was an immediate task |
| 1202 | + if hasattr(task, '_locked_resources') and task._locked_resources: |
| 1203 | + current_app = AppStatus.objects.current() |
| 1204 | +@@ -163,8 +161,6 @@ async def _aexecute_task(task): |
| 1205 | + return result |
| 1206 | + return None |
| 1207 | + finally: |
| 1208 | +- # Restore the task's GUID for proper logging (contexts.py bug workaround) |
| 1209 | +- set_guid(task.logging_cid) |
| 1210 | + # Release Redis locks if this was an immediate task |
| 1211 | + if hasattr(task, '_locked_resources') and task._locked_resources: |
| 1212 | + current_app = await sync_to_async(AppStatus.objects.current)() |
| 1213 | +-- |
| 1214 | +2.52.0 |
| 1215 | + |
| 1216 | + |
| 1217 | +From 46c224559161991c4ae29a537e94065acd18e73b Mon Sep 17 00:00:00 2001 |
| 1218 | +From: Dennis Kliban <dkliban@redhat.com> |
| 1219 | +Date: Fri, 19 Dec 2025 23:00:16 -0500 |
| 1220 | +Subject: [PATCH 8/8] Log task state after setting to running. |
| 1221 | + |
| 1222 | +--- |
| 1223 | + pulpcore/tasking/tasks.py | 16 ++++++++++++++++ |
| 1224 | + 1 file changed, 16 insertions(+) |
| 1225 | + |
| 1226 | +diff --git a/pulpcore/tasking/tasks.py b/pulpcore/tasking/tasks.py |
| 1227 | +index 23a3641ad..e52be163d 100644 |
| 1228 | +--- a/pulpcore/tasking/tasks.py |
| 1229 | ++++ b/pulpcore/tasking/tasks.py |
| 1230 | +@@ -87,6 +87,14 @@ def _execute_task(task): |
| 1231 | + |
| 1232 | + with with_task_context(task): |
| 1233 | + task.set_running() |
| 1234 | ++ # Verify task state was actually updated in database |
| 1235 | ++ db_task = Task.objects.get(pk=task.pk) |
| 1236 | ++ _logger.info( |
| 1237 | ++ "TASK STATE VERIFICATION: Task %s local state=%s, database state=%s", |
| 1238 | ++ task.pk, |
| 1239 | ++ task.state, |
| 1240 | ++ db_task.state |
| 1241 | ++ ) |
| 1242 | + domain = get_domain() |
| 1243 | + try: |
| 1244 | + log_task_start(task, domain) |
| 1245 | +@@ -145,6 +153,14 @@ async def _aexecute_task(task): |
| 1246 | + |
| 1247 | + async with awith_task_context(task): |
| 1248 | + await sync_to_async(task.set_running)() |
| 1249 | ++ # Verify task state was actually updated in database |
| 1250 | ++ db_task = await sync_to_async(Task.objects.get)(pk=task.pk) |
| 1251 | ++ _logger.info( |
| 1252 | ++ "TASK STATE VERIFICATION (async): Task %s local state=%s, database state=%s", |
| 1253 | ++ task.pk, |
| 1254 | ++ task.state, |
| 1255 | ++ db_task.state |
| 1256 | ++ ) |
| 1257 | + domain = get_domain() |
| 1258 | + try: |
| 1259 | + task_coroutine_fn = await aget_task_function(task) |
| 1260 | +-- |
| 1261 | +2.52.0 |
| 1262 | + |
0 commit comments