Skip to content
Snippets Groups Projects
Unverified Commit 1642eeab authored by Ned Batchelder's avatar Ned Batchelder Committed by GitHub
Browse files

Merge pull request #14128 from edx/jbarciauskas/PLAT-1109-ignore-integrity-error

[PLAT-1109] Suppress IntegrityErrors caused by race condition
parents 96d0adf7 caf9901c
No related merge requests found
......@@ -271,15 +271,25 @@ class DjangoXBlockUserStateClient(XBlockUserStateClient):
evt_time = time()
for usage_key, state in block_keys_to_state.items():
student_module, created = StudentModule.objects.get_or_create(
student=user,
course_id=usage_key.course_key,
module_state_key=usage_key,
defaults={
'state': json.dumps(state),
'module_type': usage_key.block_type,
},
)
try:
student_module, created = StudentModule.objects.get_or_create(
student=user,
course_id=usage_key.course_key,
module_state_key=usage_key,
defaults={
'state': json.dumps(state),
'module_type': usage_key.block_type,
},
)
except IntegrityError:
# PLAT-1109 - Until we switch to read committed, we cannot rely
# on get_or_create to be able to see rows created in another
# process. This seems to happen frequently, and ignoring it is the
# best course of action for now
log.warning("set_many: IntegrityError for student {} - course_id {} - usage key {}".format(
user, repr(unicode(usage_key.course_key)), usage_key
))
return
num_fields_before = num_fields_after = num_new_fields_set = len(state)
num_fields_updated = 0
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment