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

MTG-1110 Add request time out for DB query #362

Conversation

andrii-kl
Copy link
Contributor

  • Added configurable timeout for database queries in the API service.
  • Added new test cases to verify the behavior of the timeout mechanism.
  • Added a readme file with a second option for a global query execution time limit.

- Added configurable timeout for database queries in the API service.
- Added new test cases to verify the behavior of the timeout mechanism.
- Added a readme file with a second option for a global query execution time limit.
Copy link
Collaborator

@armyhaylenko armyhaylenko left a comment

Choose a reason for hiding this comment

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

mostly spelling comments

nft_ingester/src/api/api_impl.rs Outdated Show resolved Hide resolved
nft_ingester/src/api/api_impl.rs Show resolved Hide resolved
nft_ingester/src/api/error.rs Outdated Show resolved Hide resolved
nft_ingester/src/api/api_impl.rs Outdated Show resolved Hide resolved
nft_ingester/src/config.rs Outdated Show resolved Hide resolved
nft_ingester/tests/api_tests.rs Outdated Show resolved Hide resolved
nft_ingester/tests/api_tests.rs Outdated Show resolved Hide resolved
nft_ingester/tests/api_tests.rs Outdated Show resolved Hide resolved
nft_ingester/tests/api_tests.rs Outdated Show resolved Hide resolved
- Implemented suggestions from the PR review.
- Added readme file with some tips.
README.md Outdated Show resolved Hide resolved
nft_ingester/src/api/api_impl.rs Show resolved Hide resolved
Copy link
Contributor

@StanChe StanChe left a comment

Choose a reason for hiding this comment

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

How will postgres behave with this change? Will it terminate a query? We've had issues with PG, still executing some query after a day of the container restart... That was a heavy COPY FROM that was not even killable, but still.
Also WDYT of injecting ?statement_timeout= into the connection string on the relevant services (ingester, api)?

nft_ingester/src/api/api_impl.rs Show resolved Hide resolved
@andrii-kl
Copy link
Contributor Author

How will postgres behave with this change? Will it terminate a query? We've had issues with PG, still executing some query after a day of the container restart... That was a heavy COPY FROM that was not even killable, but still. Also WDYT of injecting ?statement_timeout= into the connection string on the relevant services (ingester, api)?

It is definitely worth adding this option ?statement_timeout=, but this solution is not relevant to the solution with the timeout function.
I see this as two different tools. In one case, we restrict any internal services from using heavy/long queries. In another case, we limit only client requests to the API. Timeout restriction on internal services may be more lenient since they are controlled.

Co-authored-by: Oleksandr Mykhailenko <[email protected]>
@andrii-kl
Copy link
Contributor Author

Another approach with db url parameter config ?statement_timeout=
#371

@andrii-kl andrii-kl closed this Jan 16, 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