mirror of
https://github.com/inventree/InvenTree.git
synced 2026-03-11 22:54:17 +00:00
fix: wrap create_default_labels in transaction.atomic() savepoint to prevent PostgreSQL transaction abort (#11484) (#11490)
When the plugin registry reloads during an active HTTP request,
create_default_labels() raises ValidationError on duplicate template
inserts. On PostgreSQL this aborts the entire outer atomic() block,
causing TransactionManagementError on all stock operations in that request.
Fixes #11469
(cherry picked from commit a964d6682e)
Co-authored-by: tigger2000ttfn <tigger2000ttfn@gmail.com>
Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
committed by
GitHub
parent
f2fa65ff1d
commit
59f3b9f2f6
@@ -7,6 +7,7 @@ from django.apps import AppConfig
|
|||||||
from django.core.exceptions import AppRegistryNotReady, ValidationError
|
from django.core.exceptions import AppRegistryNotReady, ValidationError
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.core.files.storage import default_storage
|
from django.core.files.storage import default_storage
|
||||||
|
from django.db import transaction
|
||||||
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
|
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
@@ -160,6 +161,7 @@ class ReportConfig(AppConfig):
|
|||||||
# Otherwise, create a new entry
|
# Otherwise, create a new entry
|
||||||
try:
|
try:
|
||||||
# Create a new entry
|
# Create a new entry
|
||||||
|
with transaction.atomic():
|
||||||
report.models.LabelTemplate.objects.create(
|
report.models.LabelTemplate.objects.create(
|
||||||
**template, template=self.file_from_template('label', filename)
|
**template, template=self.file_from_template('label', filename)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user