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

feat: distributed requests synchronization #13993

Merged
merged 18 commits into from
Nov 8, 2024
Merged

Conversation

mirkoSekulic
Copy link
Collaborator

@mirkoSekulic mirkoSekulic commented Nov 6, 2024

Description

Before this pr, in-memory UserRequestsSynchronizationService solution was used to synchronize parallel requests.
The solution was designed only to support one replica.

The solution is replaced in pr to support distributed locking.

Generic RequestSynchronizationMiddleware was added and designed to synchronize user requests in a distributed environment, ensuring that concurrent requests are handled without conflicts.

All explicit locking code is removed from controllers and services.

The logic for determining which endpoints will be synchronized is in the EndpointNameSyncEvaluator class.
The solution is flexible to add a new endpoint to synchronization.
The existing EndpointNameSyncEvaluator class can be used, or another class implementing IRequestSyncEvaluator can be added to the project and it will be auto-registered.

Under the hood PosstgreSql advisory locks are used to synchronize requests.
A file system is used for synchronization in the unit tests.
Gitea integration tests and Playwright tests are using advisory locks.

Related Issue(s)

  • #{issue number}

Verification

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

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@mirkoSekulic mirkoSekulic marked this pull request as draft November 6, 2024 13:07
@github-actions github-actions bot added solution/studio/designer Issues related to the Altinn Studio Designer solution. backend kind/dependencies Used for issues or pull requests that are dependency updates labels Nov 6, 2024
@github-actions github-actions bot added the quality/testing Tests that are missing, needs to be created or could be improved. label Nov 7, 2024
@mirkoSekulic mirkoSekulic force-pushed the feature/distributed-lock branch 2 times, most recently from 2c7baff to 37f6524 Compare November 7, 2024 06:59
@mirkoSekulic mirkoSekulic force-pushed the feature/distributed-lock branch 2 times, most recently from 8ba8377 to 4ae1b52 Compare November 7, 2024 14:34
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.20%. Comparing base (c9d1e52) to head (4ae1b52).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13993   +/-   ##
=======================================
  Coverage   95.20%   95.20%           
=======================================
  Files        1740     1740           
  Lines       22815    22815           
  Branches     2670     2670           
=======================================
  Hits        21722    21722           
  Misses        847      847           
  Partials      246      246           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mirkoSekulic mirkoSekulic force-pushed the feature/distributed-lock branch 5 times, most recently from c4850af to 6559d90 Compare November 8, 2024 06:43
@mirkoSekulic mirkoSekulic marked this pull request as ready for review November 8, 2024 06:59
@mirkoSekulic mirkoSekulic force-pushed the feature/distributed-lock branch from 1a9e181 to 4ec7733 Compare November 8, 2024 07:12
@mirkoSekulic mirkoSekulic changed the title feat: distributed lock feat: distributed requests synchronization Nov 8, 2024
@mlqn mlqn self-requested a review November 8, 2024 10:44
@mirkoSekulic mirkoSekulic enabled auto-merge (squash) November 8, 2024 10:52
Copy link
Contributor

@mlqn mlqn left a comment

Choose a reason for hiding this comment

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

Tested OK in dev! 🚀

@mirkoSekulic mirkoSekulic merged commit a78cd5f into main Nov 8, 2024
10 checks passed
@mirkoSekulic mirkoSekulic deleted the feature/distributed-lock branch November 8, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend kind/dependencies Used for issues or pull requests that are dependency updates quality/testing Tests that are missing, needs to be created or could be improved. solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants