-
Notifications
You must be signed in to change notification settings - Fork 281
Fix command timeout issues in DAB #2912
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
base: main
Are you sure you want to change the base?
Conversation
|
@vs-dsva please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for configuring command timeout for PostgreSQL operations in Data API Builder (DAB) to address timeout issues for long-running queries that exceed the default 30-second limit.
- Introduces a new
command-timeoutoption in data source configuration that overrides connection string timeout values - Implements PostgreSQL-specific options handling and connection string modification
- Adds comprehensive test coverage and documentation for the new feature
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Config/ObjectModel/DataSource.cs | Adds PostgreSQL options support and command timeout parsing logic |
| src/Config/RuntimeConfigLoader.cs | Updates PostgreSQL connection string processing to apply timeout configuration |
| src/Service.Tests/Configuration/ConfigurationTests.cs | Adds unit tests for command timeout functionality across database types |
| schemas/dab.draft.schema.json | Updates JSON schema to include command-timeout option for PostgreSQL and MSSQL |
| samples/postgresql-command-timeout-example.json | Provides example configuration with command timeout |
| samples/connection-string-timeout-example.json | Shows alternative connection string timeout approach |
| docs/postgresql-command-timeout.md | Documents the new command timeout feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| private int? ReadIntOption(string option) | ||
| { | ||
| if (Options is not null && Options.TryGetValue(option, out object? value)) | ||
| { | ||
| if (value is int intValue) | ||
| { | ||
| return intValue; | ||
| } | ||
| else if (value is string stringValue && int.TryParse(stringValue, out int parsedValue)) | ||
| { | ||
| return parsedValue; | ||
| } | ||
| else if (value is JsonElement jsonElement && jsonElement.ValueKind == JsonValueKind.Number && jsonElement.TryGetInt32(out int jsonValue)) | ||
| { | ||
| return jsonValue; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ReadIntOption method duplicates parsing logic found in GetCommandTimeout. Consider consolidating this logic to avoid code duplication and ensure consistent parsing behavior.
| public int GetCommandTimeout() | ||
| { | ||
| if (Options is not null && Options.TryGetValue("command-timeout", out object? value)) | ||
| { | ||
| if (value is int intValue) | ||
| { | ||
| return intValue; | ||
| } | ||
| else if (value is long longValue && longValue <= int.MaxValue && longValue >= int.MinValue) | ||
| { | ||
| return (int)longValue; | ||
| } | ||
| else if (value is string stringValue && int.TryParse(stringValue, out int parsedValue)) | ||
| { | ||
| return parsedValue; | ||
| } | ||
| } | ||
|
|
||
| return 30; // default command timeout | ||
| } |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 30 for default command timeout should be extracted as a named constant to improve maintainability and avoid duplication with the schema default value.
| "properties": { | ||
| "command-timeout": { | ||
| "type": "integer", | ||
| "description": "Command timeout in seconds for database operations", | ||
| "minimum": 0, | ||
| "default": 30 | ||
| } | ||
| }, |
Copilot
AI
Oct 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PostgreSQL schema section adds command-timeout support, but MySQL and other database types are not updated. Consider adding command-timeout support to all database types or documenting why it's only available for specific databases.
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
Offers a partial fix for #2766
This is important for queries that run longer than 30 sec (the default value) as in REST mode there are frequent 5XX type errors (waiting for headers) that resort back to this.
What is this change?
The
command timeoutparameter is not consistently passed downstream to database access libraries.Hence a new parameter in
data-source.options.command-timeoutto control it.How was this tested?
Sample Request(s)
The configuration accepts
{ "$schema": "../schemas/dab.draft.schema.json", "data-source": { "database-type": "postgresql", "connection-string": "Host=localhost;Database=bookstore;Username=postgres;Password=password;", "options": { "command-timeout": 60 } }, ...