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

introduce db timeout #1222

Merged
merged 2 commits into from
Nov 20, 2024
Merged

introduce db timeout #1222

merged 2 commits into from
Nov 20, 2024

Conversation

wintonzheng
Copy link
Contributor

@wintonzheng wintonzheng commented Nov 20, 2024

Important

Introduce database statement timeout configuration in config.py and apply it in client.py for database connections.

  • Configuration:
    • Add DATABASE_STATEMENT_TIMEOUT_MS in config.py with default 60000 ms.
  • Database Client:
    • Update DB_CONNECT_ARGS in client.py to include statement_timeout using DATABASE_STATEMENT_TIMEOUT_MS.
    • Modify create_async_engine in AgentDB to use DB_CONNECT_ARGS.

This description was created by Ellipsis for 542d30e. It will automatically update as commits are pushed.

<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Introduce database statement timeout configuration in `config.py` and apply it in `client.py` for database connections.
>
>   - **Configuration**:
>     - Add `DATABASE_STATEMENT_TIMEOUT_MS` in `config.py` with default 60000 ms.
>   - **Database Client**:
>     - Update `DB_CONNECT_ARGS` in `client.py` to include `statement_timeout` using `DATABASE_STATEMENT_TIMEOUT_MS`.
>     - Modify `create_async_engine` in `AgentDB` to use `DB_CONNECT_ARGS`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for 0c2fddc79961a2f547c354c978f30f7882ff9641. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 942020f in 20 seconds

More details
  • Looked at 41 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/db/client.py:81
  • Draft comment:
    Consider adding an else clause to handle cases where the database string does not contain postgresql+asyncpg or postgresql+psycopg. This will ensure that DB_CONNECT_ARGS is always defined appropriately.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The current implementation sets 'DB_CONNECT_ARGS' with a default value and overrides it if 'postgresql+asyncpg' is in the database string. The comment suggests that there might be other cases that need specific handling, but without evidence of such cases, the default setting seems sufficient. The comment is speculative without strong evidence of an issue.
    I might be overlooking specific database configurations that require different 'DB_CONNECT_ARGS'. However, without evidence of such cases, the default setting appears to be a reasonable fallback.
    The default setting for 'DB_CONNECT_ARGS' should cover most cases unless there is specific evidence of other configurations needing different settings.
    The comment is speculative and lacks strong evidence of an issue. The default setting for 'DB_CONNECT_ARGS' should suffice unless specific cases are identified.

Workflow ID: wflow_av1ras7Rpf6wdanP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 942020f in 23 seconds

More details
  • Looked at 41 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_qJwLPaIApJ0j48UQ


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

"options": f"-c statement_timeout={settings.DATABASE_STATEMENT_TIMEOUT_MS}",
}
if "postgresql+asyncpg" in settings.DATABASE_STRING:
DB_CONNECT_ARGS = {"server_settings": {"statement_timeout": str(settings.DATABASE_STATEMENT_TIMEOUT_MS)}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using DB_CONNECT_ARGS.update(...) instead of overwriting the dictionary to ensure other connection arguments are preserved.

Suggested change
DB_CONNECT_ARGS = {"server_settings": {"statement_timeout": str(settings.DATABASE_STATEMENT_TIMEOUT_MS)}}
DB_CONNECT_ARGS.update({"server_settings": {"statement_timeout": str(settings.DATABASE_STATEMENT_TIMEOUT_MS)}})

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 542d30e in 11 seconds

More details
  • Looked at 20 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. skyvern/forge/sdk/db/client.py:82
  • Draft comment:
    The statement_timeout value is already a string in settings.DATABASE_STATEMENT_TIMEOUT_MS, so there's no need to convert it to a string again. Consider removing the str() conversion.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The PR introduces a database statement timeout configuration. The implementation in client.py correctly updates the DB_CONNECT_ARGS based on the database string. However, the statement_timeout value for asyncpg is converted to a string, which is unnecessary since it is already a string in the settings.

Workflow ID: wflow_oC3h2mqOlUMqwngM


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@wintonzheng wintonzheng merged commit e4c1cf6 into main Nov 20, 2024
2 checks passed
@wintonzheng wintonzheng deleted the shu/db_timeout branch November 20, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant