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 for mediator load testing race condition when scaling horizontally #2009

Merged
merged 7 commits into from
Nov 9, 2022

Conversation

ianco
Copy link
Contributor

@ianco ianco commented Nov 7, 2022

Pause and retry if a routing record is not found

ianco added 5 commits November 7, 2022 12:39
Signed-off-by: Ian Costanzo <[email protected]>
Signed-off-by: Ian Costanzo <[email protected]>
Signed-off-by: Ian Costanzo <[email protected]>
Signed-off-by: Ian Costanzo <[email protected]>
Signed-off-by: Ian Costanzo <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2022

Codecov Report

Merging #2009 (ab6c64e) into main (f857f8c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #2009   +/-   ##
=======================================
  Coverage   93.51%   93.51%           
=======================================
  Files         539      539           
  Lines       34608    34625   +17     
=======================================
+ Hits        32363    32380   +17     
  Misses       2245     2245           

@swcurran swcurran changed the title Mediator load testing Fix for mediator load testing race condition when scaling horizontally Nov 8, 2022
@shaangill025
Copy link
Contributor

@ianco We can also use the Redis cache across scaled-up mediators to track if RoutingRecord for a recip_key is being created? Mediator_A before committing a new RoutingRecord to wallet adds routing_record::{recip_key} to cache. When mediator_B calls retrieve_by_recipient_key and StorageNotFoundError gets raised then we check the cache for routing_record::{recip_key} and retry only if it exists.

@ianco
Copy link
Contributor Author

ianco commented Nov 8, 2022

@ianco We can also use the Redis cache across scaled-up mediators to track if RoutingRecord for a recip_key is being created? Mediator_A before committing a new RoutingRecord to wallet adds routing_record::{recip_key} to cache. When mediator_B calls retrieve_by_recipient_key and StorageNotFoundError gets raised then we check the cache for routing_record::{recip_key} and retry only if it exists.

@shaangill025 I think using the redis (or kafka) queue is a better approach than the hack-y solution I put in. However unless we make queues a requirement (as @swcurran suggested) we also have to have a fall-back solution for when there are no queues deployed. (I think this problem can occur even if there is just a single instance of the mediator, although much less likely.)

For a redis/kafka solution, I think all that aca-py need to do - if there is no routing record found - is just leave the message on the queue with a "retry later" flag, I don't think there's a reason to do any additional checking. (Plus I'm not sure of the timing - is it possible that Mediator_B will try to find the routing record before Mediator_A even gets the request to add the routing record? I'm not sure of the root cause of this problem so we would need to assume this is a possibility.)

@ianco ianco marked this pull request as ready for review November 9, 2022 18:13
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@swcurran swcurran left a comment

Choose a reason for hiding this comment

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

Confirmed and we agree this should be merged. A subsequent update for adding queuing support in this area may be needed, but that can follow.

@ianco ianco merged commit 75c057e into openwallet-foundation:main Nov 9, 2022
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

Successfully merging this pull request may close these issues.

4 participants