Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update by bmx0r · Pull Request #8017 · pulp/pulpcore · GitHub
Skip to content

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update - #8017

Open
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152
Open

fix(0152_alter_repositoryversion_content_ids): add a batch size to avoid timeout on large update#8017
bmx0r wants to merge 1 commit into
pulp:mainfrom
bmx0r:fix/migration152

Conversation

@bmx0r

@bmx0rbmx0r commented Aug 27, 2026

Copy link
Copy Markdown

While trying to upgrade pulp this migration was killed after 10min, even after trying to tune db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution maybe this could be integrated into guidelines for future migration script

Assisted By: Claude Opus 4.8

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • Follows the Pulp policy on AI Usage

…oid timeout on large update
While trying to upgrade pulp this migration was killed after 10min, even after trying to tune
db keepalives* parameters
We are using an internal dbaas service so we do not have full access to the Database so this was the best solution
maybe this could be integrated into guidelines for future migration script
Assisted By: Claude Opus 4.8
@mdellweg

Copy link
Copy Markdown
Member

For this specific migration we have a solution in place, where you can do the change beforehand to make the actual migration basically no-op.

Classic RT*M:

https://pulpproject.org/pulpcore/docs/admin/guides/data-repair/?h=content_id#repair-7465-populate-missing-
repository-version-caches

Here it was introduced as a management command:
https://pulpproject.org/pulpcore/changes/?h=datarepair#3.106.0-rest-api-bugfix

The one thing I would think is missing here is a hint in the migration to maybe running this command in case the migration failed.

@bmx0r

Copy link
Copy Markdown
Author

@mdellweg we went from 3.76.1 → 3.116.0 and therefore we hadnt this endpoint available yet...
best practice for upgrade path are not always clear to me for pulp in general, maybe i was doing something wrong
so when we realize this we were already halfway, so we had to move forward as we were in the middle of the upgrade

Also I kinda expect that it run more or less the same kind of code resulting in the same kind of long transaction (I havent checked)

so even if I totally agree there was something already this MR was more to give the idea to allways add batch mode to future migration of that kind :)

about adding a hint, the migration was blocked so all changeset after 152 where not apply so we were probably not in a situation where we want the app to start...
Cheers
Mike

@mdellweg

Copy link
Copy Markdown
Member

So the batching may make the operation faster, but i think it does not necessarily solve the issue completely. OTOH batching it up may further the chance to hit the 65536-parameter limit of a Postgres operation (not so sure about that one, but there are definitely other resource constraints involved.). OTOH, the whole "transform the rest of the repository-versions before changing the field definition" really needs to go into one transaction (as these migrations usually do). As long as we cannot guarantee the runtime below the timeout, we are kind of stuck. And the sadest part is these errors only turn up in the actual production environment. On the small test boxes we will never run into that timeout.

In general, yes it's a good idea to keep migrations performant, and we have had similar issues before. The specifics with this one are (as you already noted with the small batchsizes) it is impossible to predict what the right batch is.

@bmx0r

Copy link
Copy Markdown
Author

Hi,
First of all i want to thank you and all the pulp community, wheter it is on forum or github there is always someone to answer and that is really appreciated :)

Luckilly, I experience this on my "small" sandbox, so I will need to reproduce my workaroud in my production soon
for the record :
SB
public | core_repositorycontent | table | core_pulp_adm | permanent | 389 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1767 MB |
core_pulp=> select count() from core_repositorycontent; --> 2988832
core_pulp=> select count(
) from core_repositoryversion; --> 6742
PR
public | core_repositorycontent | table | core_pulp_adm | permanent | 1096 MB |
public | core_repositoryversion | table | core_pulp_adm | permanent | 1104 kb |
core_pulp=> select count() from core_repositorycontent; -->8207555
core_pulp=> select count(
) from core_repositoryversion; --> 10496

about the sizing of the table or the number of version per repo: could it be an idea to add it to https://analytics.pulpproject.org/ ? maybe that would give data to improve testing ar dev. guidelines in the future

This situation also lead me to this: https://pulpproject.org/pulpcore/docs/user/guides/update-repo-retention/ (yes I read sometimes the docs ;) ) which i believe is the real root cause of my problem.
In our env by default all repo have been created without any --retain-repo-versions as we use a simple workflow where we promote from Sandbox/preprod/prod that run over 2 weeks chances are that I dont need to keep all the repo versions, so i will dig that part to free the database and the upgrade burden ;)

again some data if it can help :) (The totals below don't match the raw core_repositoryversion counts because I filtered to a subset of repos via the label selector )

foriin$(pulp rpm repository list --label-select xxxx=xxxxxx --field name | jq -r .[].name);doecho$i;pulp rpm repository version list --repository "$i" --limit 10000| jq length;done

RepositoryVersion counts Sandbox

RepositoryVersions
MR-el-8-x86_64-epel1418
MR-rhel-8-x86_64-appstream_os633
MR-el-7-x86_64-epel578
MR-rhel-8-x86_64-codeready_builder_os496
MR-rhel-8-x86_64-baseos_os405
MR-rhel-8-x86_64-baseos_debug-rpms303
MR-centos-7-x86_64-updates270
MR-rhel-10-x86_64-baseos_os142
MR-centos-7-x86_64-els124
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-puppet623
MR-el-10-x86_64-openvox822
MR-el-9-x86_64-openvox822
MR-rhel-8-x86_64-baseos_kickstart12
MR-centos-8-x86_64-highavailability_os4
MR-centos-8-x86_64-powertools_os4
MR-centos-8-x86_64-baseos_os4
MR-centos-8-x86_64-appstream_os4
MR-centos-7-x86_64-os3
MR-centos-7-x86_64-extras2
Total4539

RepositoryVersion counts — prod

RepositoryVersions
MR-el-8-x86_64-epel1527
MR-el-9-x86_64-epel1037
MR-el-7-x86_64-epel819
MR-rhel-8-x86_64-appstream_os748
MR-rhel-9-x86_64-appstream_os636
MR-rhel-8-x86_64-baseos_os558
MR-rhel-8-x86_64-codeready_builder_os530
MR-rhel-9-x86_64-codeready_builder_os457
MR-rhel-9-x86_64-baseos_os457
MR-rhel-9-x86_64-baseos_debug-rpms371
MR-el-10-x86_64-epel348
MR-rhel-8-x86_64-baseos_debug-rpms334
MR-centos-7-x86_64-updates298
MR-rhel-7-x86-64-els212
MR-rhel-10-x86_64-appstream_os210
MR-rhel-7-x86_64-os202
MR-rhel-7-x86_64-optional187
MR-rhel-7-x86_64-highavailability184
MR-rhel-7-x86-64-elsoptional175
MR-rhel-10-x86_64-baseos_os154
MR-rhel-10-x86_64-codeready_builder151
MR-centos-7-x86_64-els135
MR-rhel-7-x86_64-rhscl115
MR-rhel-8-x86_64-highavailability_os70
MR-el-7-x86_64-jbeap_7.4_os58
MR-el-8-x86_64-puppet755
MR-el-7-x86_64-puppet755
MR-rhel-7-x86_64-extras52
MR-rhel-9-x86_64-highavailability_os45
MR-rhel-7-x86_64-dotnet37
MR-el-9-x86_64-puppet732
MR-el-8-x86_64-puppet624
MR-el-7-x86_64-puppet624
MR-el-10-x86_64-openvox822
MR-rhel-7-x86_64-supplementary22
MR-rhel-9-x86_64-baseos_kickstart10
MR-rhel-9-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-appstream_kickstart10
MR-rhel-8-x86_64-baseos_kickstart9
MR-el-9-x86_64-puppet86
MR-el-8-x86_64-puppet86
MR-el-7-x86_64-puppet86
MR-rhel-10-x86_64-baseos_kickstart4
MR-rhel-7-x86_64-kickstart4
MR-rhel-10-x86_64-appstream_kickstart3
MR-rhel-7-x86_64-gluster3client3
MR-centos-8-x86_64-appstream_os3
MR-centos-7-x86_64-os3
MR-centos-8-x86_64-baseos_os3
MR-centos-8-x86_64-powertools_os3
MR-centos-8-x86_64-highavailability_os3
MR-el-7-x86_64-pg962
MR-el-9-x86_64-puppet62
MR-rhel-8-x86_64-gluster3client_os2
MR-centos-7-x86_64-extras2
Total10435

plotwist: applying retain_repo_versions synchronously deletes the excess versions inline, which blows the 5s immediate-task limit

❯ pulp rpm repository update --name MR-rhel-8-x86_64-baseos_os --retain-repo-versions 50
Started background task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/
Error: Task /pulp/api/v3/tasks/01a047e9-7f6d-76c3-bc85-e3f31594cfb4/ failed: '[PLP0024] Immediate task 01a047e9-7f6d-76c3-bc85-e3f31594cfb4 (type: pulpcore.app.tasks.base.ageneral_update) timed out after 5 seconds.'

I can do a loop and reduce it bit by bit, yet while i found this issue maybe this is a task that is a good candidate to be moved to deffered ( I saw TASK_PREFER_DEFER but it seems to be a server side task)

That is a lot of thinks/thought, if some of it is usefull and you want me to open dedicated issues feel free to shoot, I'll be happy to do it if it can help

Cheers
Mike

@dralley

Copy link
Copy Markdown
Contributor

Yeah, there is a workaround to disable the "immediate" running of tasks (https://pulpproject.org/pulpcore/docs/admin/reference/settings/#task_prefer_defer) but it would be a good idea to remove the behavior entirely for large repo version deletes. You're not the first to run into this.

#7897

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bmx0r@mdellweg@dralley