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.
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. |
|
If I’m understanding correctly, the mixed-version caveat would only apply to updates whose effective Creates, deletes, and updates that do change So the remaining ZDU concern would be narrower: it would apply only to ordinary unchanged- If that matches your reading as well, would you prefer to keep the current scoped change, or would you want the mixed-version case addressed in this PR too? |
|
I am certain that destroying a distribution can only release a base_path and so cannot even conflict with a prefixed-overlapped base_path that is created at the same time around. (Either the create fails, or the delete succeeded first. In any case the result is consistent wrt the overlap constraint.) As for the ZDU concerns, I think if we aquire the existing domain-scoped lock shared, and introduce a new (uhhh, regrets...) domain-scoped-base-path lock to use alongside the specific entity lock, we'd be completely safe. |
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.