Skip to content

fix: Use managed read transactions for queries in metadata service #2119

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

Merged
merged 2 commits into from
Mar 22, 2023

Conversation

kristenarmes
Copy link
Contributor

Description

Updating metadata GET APIs to use managed read transactions in the Neo4j proxy to provide retry capabilities.

Motivation and Context

We were having an issue with errors with our health check where our Neo4j instance was showing that our client connection was closing, so trying this out to see if it fixes the issue. In any case, it is the Neo4j recommended way of executing transactions.

How Has This Been Tested?

  • Ran the existing tests
  • Started the service locally and hit multiple of the GET endpoints to verify that results were returned

Documentation

N/A

CheckList

  • PR title addresses the issue accurately and concisely
  • Updates Documentation and Docstrings
  • Adds tests
  • Adds instrumentation (logs, or UI events)

@boring-cyborg boring-cyborg bot added the area:metadata From the metadata folder label Mar 21, 2023
@kristenarmes kristenarmes marked this pull request as ready for review March 21, 2023 02:00
if LOGGER.isEnabledFor(logging.DEBUG):
LOGGER.debug('Executing Cypher query: {statement} with params {params}: '.format(statement=statement,
params=param_dict))
start = time.time()
try:
with self._driver.session(database=self._database_name) as session:
result = session.run(query=statement, **param_dict)
return [record for record in result]
return session.read_transaction(execute_statement, statement, param_dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make the return the same on the execute_statement function. So rather than doing .data() doing [record for record in result]. I am not sure if using .data() could cause a mismatch in the expected returned data type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes this is a good point, I was having trouble getting the results originally so I thought it needed to be done a different way, but turns out I was just doing it in the wrong spot. just updated this so the original return way is used, but just in the transaction function instead of here

Signed-off-by: Kristen Armes <[email protected]>
@kristenarmes kristenarmes merged commit 61ef5d8 into main Mar 22, 2023
@kristenarmes kristenarmes deleted the karmes-metadata-use-managed-read-transactions branch March 22, 2023 21:03
B-T-D pushed a commit to B-T-D/amundsen that referenced this pull request Mar 29, 2023
…mundsen-io#2119)

* Use managed read transactions for queries in metadata service

Signed-off-by: Kristen Armes <[email protected]>

* Return same type as before

Signed-off-by: Kristen Armes <[email protected]>

---------

Signed-off-by: Kristen Armes <[email protected]>
Signed-off-by: Ben Dye <[email protected]>
B-T-D pushed a commit to B-T-D/amundsen that referenced this pull request Mar 29, 2023
…mundsen-io#2119)

* Use managed read transactions for queries in metadata service

Signed-off-by: Kristen Armes <[email protected]>

* Return same type as before

Signed-off-by: Kristen Armes <[email protected]>

---------

Signed-off-by: Kristen Armes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metadata From the metadata folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants