<div dir="ltr"><div>I strongly support this, or at least strongly support having a discussion about it.  I think we can't make this change for Pulp 3, but we should absolutely consider moving in this direction for Pulp 4.</div><div><br></div><div>One (IMO large) "pro" which I didn't see mentioned here is auditability. It is essentially impossible to know details like "what particular sync options was a sync performed with" (because the remote settings can change, you can't make assumptions about what it was at the time).  I can definitely imagine that some users might strongly value that kind of information and there's not really a good way to provide answers to those questions under the current design.</div><div><br></div><div>So in addition to solving various difficult problems that can lead to headaches for both ourselves and our users, there's also some potential for creating new value here.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 12, 2020 at 11:25 AM Matthias Dellweg <<a href="mailto:mdellweg@redhat.com">mdellweg@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Today we met to brainstorm about the pulp design around locking and<br>
the resource manager.<br>
Here's the meeting transcript:<br>
<br>
# djnd (Lockless Pulp)<br>
<br>
# General Problem Statements<br>
<br>
- Resource manager is a problem.<br>
    - It's a bottleneck. Every task goes through the resource manager.<br>
- When tasks die, inconsistent state rq vs Pulp<br>
- Pulp is inefficient. It's always FIFO when that may not be optimal.<br>
    - Work has to wait if there's a reservation ahead of it waiting<br>
for another resource<br>
- Orphan cleanup blocks all work<br>
    - Orphan cleanup might be handled separately by assuring that any<br>
resource the is to be clean up (currently content units and artifacts)<br>
is owned by at least one thing (RepositoryVersion, Task or User) at<br>
any time until not needed anymore<br>
<br>
<br>
# Why do we have mutable resources?<br>
<br>
Some things are immutable, e.g. content, but other things do, e.g. a<br>
Repository's data, e.g. it's name.<br>
<br>
* Mutable data creates write-write race conditions<br>
* Users have a first-come-first-serve (FCFS) expectation, e.g. a<br>
sync-then-publish<br>
<br>
<br>
# Why do we use locking today?<br>
<br>
* We use it to solve the base-path problem for Distributions<br>
* It provides the FCFS guarantee of work w.r.t a specific resource,<br>
e.g. Respotiory<br>
* Orphan cleanup is a singleton so it locks content units that are in<br>
use by other tasks when deleting<br>
* Deletion of resources is synchronized by locking<br>
* Updating of resources is synchronized by locking<br>
* Creation of RepositoryVersions is serialized by locking on the Repository<br>
<br>
<br>
# Solution<br>
<br>
...getting out of the synchronization quadrant with immutability...<br>
Locks or bottlenecks are needed to prevent usage of resources by one<br>
process, while being changed by another.<br>
If all resources were immutable, they could be used by an unlimited<br>
number of processes simultaneously.<br>
<br>
Pros:<br>
  - no need for resource manager<br>
  - all (remaining) services are scalable<br>
<br>
Cons:<br>
  - Harder to design<br>
<br>
<br>
## Exposed immutability<br>
<br>
*All* resources are immutable<br>
<br>
Pros:<br>
  - relatively easy to implement; no need to redesign the database<br>
  - blockless; no waiting on resources, ever (the user has to wait...)<br>
  - another user cannot modify ad resource you are about to use<br>
<br>
Cons:<br>
  - all burden pushed to the user<br>
  - changing a resource requires replacing it<br>
  - unable to change parameters behind a "name" (natural key)<br>
<br>
## Futures (delayed immutability)<br>
<br>
Resources are created as futures and resolved by tasks.<br>
Once resolved, resources are immutable.<br>
Resources start in the unshared mutable corner and move to the shared<br>
immutable corner.<br>
Futures can readily be used to create new resources while not yet resolved.<br>
<br>
Pros:<br>
  - accounts for actions like sync, publish to take time<br>
  - futures form a DAG -> no possibility for dead locks<br>
  - still no waiting on finished resources<br>
<br>
Cons:<br>
  - waiting on resources; blocking<br>
  - futures can fail while waiting on failing dependent futures<br>
<br>
## Copy-on-write with lookup table<br>
<br>
Resources are immutable, and referenced by a key lookup table.<br>
Changing a resource means creating a modified copy and changing the<br>
reference in the lookup table.<br>
Tasks reference the actual resources.<br>
<br>
Pros:<br>
  - users can "change" resources as they are used to<br>
  - blockless; no waiting on resources, ever (the user has to wait...)<br>
  - tasks can never fail on missing resources (being deleted in the meantime)<br>
<br>
Cons:<br>
  - extra table join on lookup<br>
  - impossible to retrieve the natural key<br>
<br>
_______________________________________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
<br>
</blockquote></div>