From 2434804e890e90f3cd5fc9588fc87db848cf4277 Mon Sep 17 00:00:00 2001 From: Grant Gainey Date: Tue, 3 Mar 2026 14:49:53 -0500 Subject: [PATCH] Update several auto-created id fields/sequences to be BIGINT. fixes #2080. (cherry picked from commit 76528efe32e82c4f53f9cb6102e85d82b2528eac) --- CHANGES/2080.bugfix | 3 +++ pulp_container/app/__init__.py | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 CHANGES/2080.bugfix diff --git a/CHANGES/2080.bugfix b/CHANGES/2080.bugfix new file mode 100644 index 000000000..45117429d --- /dev/null +++ b/CHANGES/2080.bugfix @@ -0,0 +1,3 @@ +Altered several id-fields and their related sequences. + +INTEGER AutoField sequences can "run out" on large/old instances, update to BIGINT. diff --git a/pulp_container/app/__init__.py b/pulp_container/app/__init__.py index 269d19d7d..1e49187fe 100644 --- a/pulp_container/app/__init__.py +++ b/pulp_container/app/__init__.py @@ -1,4 +1,21 @@ from pulpcore.plugin import PulpPluginAppConfig +from django.db import connection +from django.db.models.signals import post_migrate + +update_sequences_to_bigint = """ +ALTER TABLE container_blobmanifest ALTER COLUMN id TYPE bigint; +ALTER TABLE container_manifestlistmanifest ALTER COLUMN id TYPE bigint; +ALTER TABLE container_containerpushrepository_pending_blobs ALTER COLUMN id TYPE bigint; +ALTER TABLE container_containerpushrepository_pending_manifests ALTER COLUMN id TYPE bigint; +ALTER TABLE container_containerrepository_pending_manifests ALTER COLUMN id TYPE bigint; +ALTER TABLE container_containerrepository_pending_blobs ALTER COLUMN id TYPE bigint; +ALTER SEQUENCE container_blobmanifest_id_seq AS BIGINT; +ALTER SEQUENCE container_manifestlistmanifest_id_seq AS BIGINT; +ALTER SEQUENCE container_containerpushrepository_pending_blobs_id_seq AS BIGINT; +ALTER SEQUENCE container_containerpushrepository_pending_manifests_id_seq AS BIGINT; +ALTER SEQUENCE container_containerrepository_pending_blobs_id_seq AS BIGINT; +ALTER SEQUENCE container_containerrepository_pending_manifests_id_seq AS BIGINT; +""" class PulpContainerPluginAppConfig(PulpPluginAppConfig): @@ -10,6 +27,14 @@ class PulpContainerPluginAppConfig(PulpPluginAppConfig): python_package_name = "pulp-container" domain_compatible = True + @staticmethod + def update_sequences(sender, **kwargs): + """Update database sequences to bigint type after migrations.""" + with connection.cursor() as cursor: + cursor.execute(update_sequences_to_bigint) + def ready(self): super().ready() from . import checks + + post_migrate.connect(PulpContainerPluginAppConfig.update_sequences, sender=self)