Skip to content

Conversation

@jobselko
Copy link
Contributor

No description provided.

@jobselko
Copy link
Contributor Author

Minimal changes based on #1073

Comment on lines +147 to +151
sid = transaction.savepoint() # Start a savepoint
try:
Artifact.objects.bulk_create(artifact_batch.values(), batch_size=BATCH_SIZE)
except IntegrityError:
transaction.savepoint_rollback(sid) # Only rollback this batch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should solve TransactionManagementError

Comment on lines +147 to +151
sid = transaction.savepoint() # Start a savepoint
try:
Artifact.objects.bulk_create(artifact_batch.values(), batch_size=BATCH_SIZE)
except IntegrityError:
transaction.savepoint_rollback(sid) # Only rollback this batch
Copy link
Contributor

@gerrod3 gerrod3 Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sid = transaction.savepoint() # Start a savepoint
try:
Artifact.objects.bulk_create(artifact_batch.values(), batch_size=BATCH_SIZE)
except IntegrityError:
transaction.savepoint_rollback(sid) # Only rollback this batch
try:
with transaction.atomic():
Artifact.objects.bulk_create(artifact_batch.values(), batch_size=BATCH_SIZE)
except IntegrityError:

An atomic block should handle all this, a nested transaction is just savepoints behind the scenes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jobselko jobselko closed this Jan 21, 2026
@jobselko jobselko deleted the tmp_mig_19 branch January 21, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants