Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential creation of duplicate LtiConfiguration models #487

Open
Zacharis278 opened this issue Jul 8, 2024 · 0 comments
Open

Potential creation of duplicate LtiConfiguration models #487

Zacharis278 opened this issue Jul 8, 2024 · 0 comments

Comments

@Zacharis278
Copy link
Contributor

Zacharis278 commented Jul 8, 2024

Problem

On the edx.org site we have noticed a small number of LtiConfiguration objects show up that are duplicates for the same block location. This should not be possible since we only every create one LtiConfiguration per block based on the get_or_create call referenced below. This in the only function that can create an LtiConfiguration instance.

lti_config, _ = LtiConfiguration.objects.get_or_create(location=block_location)

However, this constraint is only enforced in code and not at the database level. If multiple calls to this function are received concurrently on a site with multiple workers, it is possible to end up with multiple objects.

I believe this is the cause for two reasons:

  1. All duplicate instances have adjacent database ids
  2. During a period of degraded site performance or even a bad client network connection it is easy to POST multiple requests. The modal to save the lti configuration does not close or disable while a request is in flight.

Impact

If there are multiple configurations with the same location identifier the LTI unit will not render due to a lti_consumer.models.LtiConfiguration.MultipleObjectsReturned error when any code attempts to reference that config.

Possible Solutions

  1. Add a database constraint to enforce the location attribute is unique.
    • This might be tricky to release since the new constraint will fail without manually cleaning up this data. It's possible other site unknowingly have this problem.
  2. Alter the UI so it's less likely a user could submit the same configuration multiple times.
    • Doesn't fix the underlying issue but may make it less likely to occur
@Zacharis278 Zacharis278 changed the title Potential race condition creating LtiConfiguration model Potential creation of duplicate LtiConfiguration models Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant