Task #3184

Updated by almost 3 years ago

The current implementation of the publishing task starts an outer transaction. This is undesirable because:
* Long running transactions can accumulate DB locks which can result in contention.
* Could exceed DB limitations on rollback segement.
* Prevents progress reports from being committed.

with transaction.atomic():
needs to be removed.

Without the outer transaction, each plugin will need to periodically commit for performance reasons (we don't want 5k commits).

Without the outer transaction, the publication will be committed _half-baked_. There needs to be a way to prevent the publication from being used before it is completely constructed. Suggestions have been made to add like a _visible_ attribute that is False during publishing and set True on success. Historically, the term _visible_ as strong ties to user interfaces. I propose the more appropriate boolean field name _valid_ be used. At the beginning of each task, any previous publications created by the (same) publisher that are still marked _valid=False_ _visible=False_ would deleted to clean things up. Any code that uses publications would need to be updated to only use _valid=True_ _visible=True_ publications. This includes association to Distributions.