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: connection reuse with multi-tenancy #3543

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

dbluhm
Copy link
Contributor

@dbluhm dbluhm commented Feb 26, 2025

When using multi-tenancy, calls to POST /out-of-band/receive-invitation?use_existing_connection=true would fail with a record not found error, despite connection reuse actually being completed in the background.

The issue has to do with this line:

if waiting_profile == profile:

During OOB handling, the receive invitation handler will asynchronously wait for connection reuse to complete before returning. The offending line above is within the code that waits for the events indicating connection reuse has completed. The issue is that, in multi-tenancy mode, there can be multiple profile instances, causing the equality check waiting_profile == profile to fail even though the profiles were pointing to the same logical profile because they did not point to the exact same instance.

This change adds an equality check for profiles that takes into account that multiple instances may exist that all point to the same logical profile by comparing profile names (which are guaranteed to be unique across profiles as of #3470).

As an aside, we should seriously consider removing this asynchronous waiting code. It is brittle and prone to breakage and does not adequately handle clustered environments. I regret to admit that I originally introduced the wait_for_event method (almost 4 years ago!) but I ultimately removed its use in the scenario I introduced it for. There are only two remaining instances of it being used, both of which are in OOB.

This (hopefully) resolves an issue that @thiagoromanos reported on discord in this message: https://discord.com/channels/1022962884864643214/1286299858994462842/1343937904803840063

Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
@dbluhm dbluhm force-pushed the fix/mt-connection-reuse branch from 59bd405 to a7330a8 Compare February 26, 2025 19:54
Copy link
Contributor

@thiagoromanos thiagoromanos left a comment

Choose a reason for hiding this comment

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

Tested in multi-tenant (both single-wallet-askar and basic) and in single tenant, and it worked fine. LGTM

@jamshale
Copy link
Contributor

Thanks. That's a tricky one 👍

@jamshale jamshale merged commit 3057c0e into openwallet-foundation:main Feb 26, 2025
11 checks passed
ff137 pushed a commit to didx-xyz/acapy that referenced this pull request Feb 27, 2025
ff137 pushed a commit to didx-xyz/acapy that referenced this pull request Feb 27, 2025
ff137 pushed a commit to didx-xyz/acapy that referenced this pull request Feb 27, 2025
ff137 pushed a commit to didx-xyz/acapy that referenced this pull request Feb 28, 2025
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.

3 participants