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

GetAllSubjectResources can cause dbcontext concurrency error #1649

Closed
knuhau opened this issue Jan 3, 2025 · 0 comments
Closed

GetAllSubjectResources can cause dbcontext concurrency error #1649

knuhau opened this issue Jan 3, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@knuhau
Copy link
Collaborator

knuhau commented Jan 3, 2025

Description

Calls to GetAllSubjectResources can cause dbcontext concurrency error

Reproduction

  1. For local reproduction, set FusionCache duration on the SubjectResource cache to 1 second here
  2. Call /api/v1/serviceowner/dialogs/ with a enduserId and a ServiceResource

Expected behavior

Returns dialog(s) belonging to the indicated ServiceResource and visible to the given EnduserId

Actual behavior

500: Internal Server Error
System.InvalidOperationException
A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913.

Additional information

@knuhau knuhau added the bug Something isn't working label Jan 3, 2025
@knuhau knuhau self-assigned this Jan 3, 2025
knuhau added a commit that referenced this issue Jan 6, 2025
…1648)

Add dedicated scope and dbcontext to GetSubjectResources to avoid
concurrency errors

<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Related Issue(s)

- #1649

## Verification

- [x] **Your** code builds clean without any errors or warnings
- [x] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)
@elsand elsand moved this to Code Review og PR in Dialogporten / Arbeidsflate - NY Jan 9, 2025
@knuhau knuhau moved this from Code Review og PR to Testing in Dialogporten / Arbeidsflate - NY Jan 13, 2025
@elsand elsand moved this from Testing to Done in Dialogporten / Arbeidsflate - NY Jan 15, 2025
@elsand elsand closed this as completed by moving to Done in Dialogporten / Arbeidsflate - NY Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants