Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid creating duplicate LTIContext records
NumbasLTIResourceMiddleware was doing two separate queries to get an existing LTIContext object, or create one if it doesn't exist. This can lead to multiple records being created by separate threads. This commit changes that code to use the `get_or_create` method in one atomic transaction, and adds a `unique_together` constraint on LTIContext so a duplicate can't be created.
- Loading branch information
1 parent
9539309
commit 01e1762
Showing
4 changed files
with
38 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
numbas_lti/migrations/0074_alter_lticontext_unique_together.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 3.2.14 on 2022-10-13 07:19 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('numbas_lti', '0073_resource_require_lockdown_app'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterUniqueTogether( | ||
name='lticontext', | ||
unique_together={('context_id', 'instance_guid')}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters