Narrow distribution task locks for unchanged base_path#7896
Conversation
|
Can you add a changelog for this issue? #3322 |
c74e46f to
6faf576
Compare
|
Done :) |
|
Not sure what is up with lint, maybe try rebasing with main. Also can you add |
6faf576 to
cb2a1be
Compare
|
I'd like it to be backported to at least the release(s) that are part of Satellite 6.19.z. |
a15c525 to
951ea58
Compare
…path Only reserve the domain-wide distributions resource for operations that can affect base_path overlap validation. Distribution creates, deletes, and updates that change base_path continue to reserve `pdrn:<domain>:distributions`, while updates that leave base_path unchanged now reserve only the distribution instance itself. This reduces unnecessary serialization of `ageneral_update` tasks for ordinary distribution updates, including partial PATCH requests that omit base_path or send the existing base_path unchanged. Add a functional test covering the reserved resources used for create, partial update without base_path, partial update with unchanged base_path, partial update with changed base_path, and delete. Co-authored-by: Cursor <cursoragent@cursor.com>
951ea58 to
b4d28e3
Compare
mdellweg
left a comment
There was a problem hiding this comment.
I am a tiny bit concerned about Zero Downtime Upgrades here.
An old task (dispatched before this change) updating a distribution would only lock on the domain:distributions and a new one only on the single distribution.
Since distributions themselves are rather shallow, I cannot think about a situation where this collision leads to real world impacts. But my lack of imagination here is no guarantee for correctness.
| """ | ||
| Reserve the narrowest safe lock for async distribution operations. | ||
|
|
||
| Creates, deletes, and base_path changes still lock the domain-wide distributions resource |
There was a problem hiding this comment.
Maybe add a statement that "base_path overlap validation" is the main concern why this function even exists.
I'm wondering if we can safely assume that deleting a distribution will never violate base_path overlaps?
There was a problem hiding this comment.
Yes, that is the main reason this logic exists, and I can make that clearer in the docstring.
I would still keep deletes on the broader lock. A delete does not create an overlap by itself, but it does release a base_path, so it is still part of the same domain-wide consistency concern as creates and moves.
| return [instance, domain_distributions] | ||
|
|
||
| request_data = getattr(getattr(self, "request", None), "data", {}) | ||
| requested_base_path = request_data.get("base_path", instance.base_path) |
There was a problem hiding this comment.
How come this is not None for a patch call that does not contain "base-path".
The test suggests, it actually works though (assuming it would actually pass once the linting works again).
There was a problem hiding this comment.
For a PATCH that does not include base_path, we treat that as base_path staying unchanged, so it stays on the instance-only lock.
The test is meant to cover exactly that case. If it helps, I can rewrite that branch to make the “field omitted means unchanged” behavior more explicit.
There was a problem hiding this comment.
Oh you feed the current value as default. Never mind. Ignore me on this.
Thanks, I think this is the main caveat in the current approach. From our look at the code, we see two ways to address the ZDU concern:
Both approaches would keep the current concurrency improvement while restoring compatibility with older broad-lock tasks during mixed-version upgrades. |
But only if it doesn't actually change the base path, right? Tasks that do touch base_path would retain the domain:distributions lock. That seems OK. |
Problem
Async distribution CUD operations currently reserve the domain-wide
pdrn:<domain>:distributionsresource unconditionally. For ordinaryupdates that leave
base_pathunchanged, this serializes unrelatedpulpcore.app.tasks.base.ageneral_updatetasks behind a single lock.This showed up as a bottleneck during capsule sync, where many
RefreshDistributionupdates can run at once but end up waiting on thesame domain-wide reservation.
What this changes
This patch narrows distribution task reservations when the effective
base_pathdoes not change:base_path: keep the broader lockbase_path: reserve only the distribution instanceThe implementation also handles partial
PATCHrequests correctly byfalling back to
instance.base_pathwhenbase_pathis omitted from therequest body.
Test coverage
Adds a functional test covering the reservation behavior for:
base_pathin the payloadbase_pathbase_pathPerformance notes
Tested with Satellite 6.20 Stream,
~175 capsules, 15 Pulp workers).
For completed
pulpcore.app.tasks.base.ageneral_updatetasks, lock usageshifted from all domain-wide reservations to a mix of domain and
instance-scoped reservations:
Block wait times improved substantially:
These results are consistent with removing unnecessary serialization for
ordinary distribution updates while preserving the broader lock when the
base_pathnamespace can change.