Skip to content

Commit

Permalink
Merge pull request #242 from sktston/feature/revert-avoid-slow-query
Browse files Browse the repository at this point in the history
Revert optimization for avoiding slow query
  • Loading branch information
baegjae authored Feb 17, 2024
2 parents 9dfb845 + 054b9a3 commit daa4d27
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions aries_cloudagent/protocols/connections/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,26 +627,25 @@ async def receive_request(
)
elif not self.profile.settings.get("public_invites"):
raise ConnectionManagerError("Public invitations are not enabled")
# SKT: (temporal) do not reuse connection to avoid slow query
# else: # request from public did
# # SKT: reuse connection if exist
# async with self.profile.session() as session:
# tag_filter = {"their_did": request.connection.did}
# conn_records = await ConnRecord.query(
# session,
# tag_filter=tag_filter,
# )
# if conn_records:
# if len(conn_records) > 1:
# self._logger.warning("delete duplicate connections for their_did %s", request.connection.did)
# conn_del_records = conn_records[1:] # delete records except first
# for conn_record in conn_del_records:
# await conn_record.delete_record(session)
# connection = conn_records[0] # use first record
# connection.state = ConnRecord.State.REQUEST.rfc160
# connection.invitation_msg_id = (request._thread and request._thread.pthid) or None
# connection.their_label = request.label
# await connection.save(session, reason="connection is reused")
else: # request from public did
# SKT: reuse connection if exist
async with self.profile.session() as session:
tag_filter = {"their_did": request.connection.did}
conn_records = await ConnRecord.query(
session,
tag_filter=tag_filter,
)
if conn_records:
if len(conn_records) > 1:
self._logger.warning("delete duplicate connections for their_did %s", request.connection.did)
conn_del_records = conn_records[1:] # delete records except first
for conn_record in conn_del_records:
await conn_record.delete_record(session)
connection = conn_records[0] # use first record
connection.state = ConnRecord.State.REQUEST.rfc160
connection.invitation_msg_id = (request._thread and request._thread.pthid) or None
connection.their_label = request.label
await connection.save(session, reason="connection is reused")

LOGGER.info("TEMP_LOG_0629 " + "after if connection")

Expand Down Expand Up @@ -1178,9 +1177,7 @@ async def resolve_inbound_connection(self, receipt: MessageReceipt) -> ConnRecor
if "connections/1.0/request" in receipt.raw_message:
LOGGER.info("TEMP_LOG_0629 " + "start resolve_inbound_connection")

# SKT: (temporal) do not reuse connection to avoid slow query
# if receipt.sender_verkey:
if receipt.sender_verkey and "connections/1.0/request" not in receipt.raw_message:
if receipt.sender_verkey:
try:
receipt.sender_did = await self.find_did_for_key(receipt.sender_verkey)
except StorageNotFoundError:
Expand Down

0 comments on commit daa4d27

Please sign in to comment.