Skip to content

Commit

Permalink
Add task indices to pulpcore 3.49
Browse files Browse the repository at this point in the history
  • Loading branch information
sjha4 authored and pcreech committed Aug 29, 2024
1 parent f298917 commit 537bd8d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
75 changes: 75 additions & 0 deletions packages/python-pulpcore/0001-Add-task-indices-migration.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
From 5fed107c8182a36e64d654618d17e021b1545cb3 Mon Sep 17 00:00:00 2001
From: Matthias Dellweg <[email protected]>
Date: Tue, 14 May 2024 10:09:28 +0200
Subject: [PATCH] Add some indices to task table

On large systems the queries used by the workers to identify ready tasks
can get rather slow. Specifically the single query in dispatch to identify
wheter an immediate task is ready to be executed is should be sped up
drastically.

fixes #5367
---
CHANGES/5367.feature | 1 +
...k_core_task_unblock_2276a4_idx_and_more.py | 25 +++++++++++++++++++
pulpcore/app/models/task.py | 7 +++++-
3 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 CHANGES/5367.feature
create mode 100644 pulpcore/app/migrations/0118_task_core_task_unblock_2276a4_idx_and_more.py

diff --git a/CHANGES/5367.feature b/CHANGES/5367.feature
new file mode 100644
index 0000000000..92cf748f3d
--- /dev/null
+++ b/CHANGES/5367.feature
@@ -0,0 +1 @@
+Added search indices to the Task table to speed up task operations.
diff --git a/pulpcore/app/migrations/0118_task_core_task_unblock_2276a4_idx_and_more.py b/pulpcore/app/migrations/0118_task_core_task_unblock_2276a4_idx_and_more.py
new file mode 100644
index 0000000000..248d0fd671
--- /dev/null
+++ b/pulpcore/app/migrations/0118_task_core_task_unblock_2276a4_idx_and_more.py
@@ -0,0 +1,25 @@
+# Generated by Django 4.2.11 on 2024-05-14 08:07
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("core", "0117_task_unblocked_at"),
+ ]
+
+ operations = [
+ migrations.AddIndex(
+ model_name="task",
+ index=models.Index(fields=["unblocked_at"], name="core_task_unblock_2276a4_idx"),
+ ),
+ migrations.AddIndex(
+ model_name="task",
+ index=models.Index(fields=["state"], name="core_task_state_61f0ca_idx"),
+ ),
+ migrations.AddIndex(
+ model_name="task",
+ index=models.Index(fields=["state", "pulp_created"], name="core_task_state_3742f2_idx"),
+ ),
+ ]
diff --git a/pulpcore/app/models/task.py b/pulpcore/app/models/task.py
index 3cf5fd62b4..31ca61bb93 100644
--- a/pulpcore/app/models/task.py
+++ b/pulpcore/app/models/task.py
@@ -278,7 +278,12 @@ def refresh_from_db(self, using=None, fields=None, **kwargs):
super().refresh_from_db(using, fields, **kwargs)

class Meta:
- indexes = [models.Index(fields=["pulp_created"])]
+ indexes = [
+ models.Index(fields=["pulp_created"]),
+ models.Index(fields=["unblocked_at"]),
+ models.Index(fields=["state"]),
+ models.Index(fields=["state", "pulp_created"]),
+ ]
permissions = [
("manage_roles_task", "Can manage role assignments on task"),
]
6 changes: 5 additions & 1 deletion packages/python-pulpcore/python-pulpcore.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

Name: python-%{pypi_name}
Version: 3.49.17
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Pulp Django Application and Related Modules

License: GPLv2+
URL: https://pulpproject.org
Source0: https://files.pythonhosted.org/packages/source/p/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
Patch0001: 0001-Add-task-indices-migration.patch
BuildArch: noarch

BuildRequires: python%{python3_pkgversion}-devel
Expand Down Expand Up @@ -193,6 +194,9 @@ done


%changelog
* Thu Aug 22 2024 Samir Jha <[email protected]> - 3.49.17-2
- Apply patch to add indices to task table

* Mon Aug 12 2024 Foreman Packaging Automation <[email protected]> - 3.49.17-1
- Update to 3.49.17

Expand Down

0 comments on commit 537bd8d

Please sign in to comment.