fix: connection reuse with multi-tenancy #3543
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
acapy/acapy_agent/core/event_bus.py
Line 179 in 6b228d7
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