Azure / Azure/data-api-builder
[Enhancement]: Expose Command Timeout
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 370
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 8
Description
## What?
Introduce a command timeout.
## Why?
Today, the only `timeout` value supported is in the connection string. This is the threshold for connecting to the database. This is NOT a timeout for query execution.
In our current [`PrepareDbCommand`](https://github.com/Azure/data-api-builder/blob/48d1f8f5f2837a7efb09b71725a30aa229af56be/src/Core/Resolvers/QueryExecutor.cs#L343-L357) method, we do not set an explicit timeout. Instead, we accept the default timeout ([which is 30 seconds](https://github.com/microsoft/referencesource/blob/f7df9e2399ecd273e90908ac11caf1433e142448/System.Data/System/Data/Common/AdapterUtil.cs#L1845)) which is fine for many queries but not for every query.
## Config file change
Add optional `command-timeout-seconds` under `data-source`.
```json
{
"data-source": {
"command-timeout-seconds":
}
}
```
1. Copy the defaults of [`CommandTimeout`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlcommand.commandtimeout?view=sqlclient-dotnet-core-6.0).
1. Copy the supported range of [`CommandTimeout`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlcommand.commandtimeout?view=sqlclient-dotnet-core-6.0).
1. Ensure this works for MSSQL, SQLDW, PG, MYSQL, and Cosmos.
### Additional
1. Add JSON Schema property
1. Add JSON Schema constraints
1. Add to `dab configure --data-source.command-timeout-seconds`
1. Add to `dab validate` (not required because of JSON schema)
1. Add to DAB documentation
#### Sample JSON schema
```json
"command-timeout-seconds": {
"type": "integer",
"title": "Command Timeout Seconds",
"description": "The wait time (in seconds) before terminating a command execution attempt and generating an error. Applies to query execution, not connection.",
"minimum": 0,
"maximum": 2147483647,
"default": 30
}
```
## Related
- #2750
Contributor guide
Assessment
This issue has not been assessed yet.