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

Fix schedule concurrency errors #2277

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Fix schedule concurrency errors #2277

merged 1 commit into from
Sep 11, 2024

Conversation

Fosol
Copy link
Collaborator

@Fosol Fosol commented Sep 11, 2024

A common error is related to updated the schedule event. It will often throw an optimistic concurrency error due to various race conditions. This new code will attempt to resolve that type of issue by fetch the latest, reapplying changes and then saving.

Summary

  • Updated Scheduler Service
  • Updated Event Handler Service (for clearing folders)
  • Updated Reporting Service

@Fosol Fosol added the bug Something isn't working label Sep 11, 2024
@Fosol Fosol self-assigned this Sep 11, 2024
public async Task<T> HandleConcurrencyAsync<T>(Func<Task<T>> callbackDelegate)
{
// Keep trying to update the record and handle concurrency errors.
while (true)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Essentially keep trying until successful. It will only error out if the exception is not a optimistic concurrency error.

{
// If it's a concurrency error, keep trying. Otherwise throw the error.
this.Logger.LogError(ex, "Failed to complete request. Determining if this is a concurrency error.");
var data = ex.Data["Body"] as string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I couldn't find a safe way to determine if the key exists in the dictionary. Regrettably .net uses a IDictionary object that doesn't have those features.

@Fosol Fosol merged commit c96b8ca into bcgov:dev Sep 11, 2024
1 check passed
@Fosol Fosol deleted the concurrent branch September 11, 2024 16:01
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
None yet
Development

Successfully merging this pull request may close these issues.

1 participant