Azure / Azure/azure-rest-api-specs

GatewayTimeout for `Microsoft.Sql/databases` with `api-version=2014-04-01` / package version `2017-03-01-preview`

Open
#16,897 7 comments 0 reactions 0 assignees View on GitHub
Service Attention SQL
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

@azureSQLGitHub When trying to switch Zone Redundancy a SQL database with package version 2017-03-01-preview of the Microsoft.Sql API, GatewayTimeouts are showing up:
```bash
2021/11/29 10:50:29 [DEBUG] AzureRM Request:
PUT /subscriptions//resourceGroups/acctestRG-211129104546431506/providers/Microsoft.Sql/servers/acctestsqlserver211129104546431506/databases/acctestdb211129104546431506?api-version=2014-04-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.17.2 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v59.2.0 sql/2017-03-01-preview HashiCorp Terraform/1.0.10 (+https://www.terraform.io) Terraform Plugin SDK/2.8.0 terraform-provider-azurerm/acc pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 315
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: fbcfa19c-ed4a-d048-f9a0-ace304659c50
Accept-Encoding: gzip

{"location":"westeurope","properties":{"collation":"SQL_Latin1_General_CP1_CI_AS","createMode":"Default","edition":"Premium","maxSizeBytes":"1073741824","readScale":"Disabled","requestedServiceObjectiveId":"7203483a-c4fb-4304-9e9f-17c71c904f5d","requestedServiceObjectiveName":"P1","zoneRedundant":false},"tags":{}}
2021/11/29 10:51:29 [DEBUG] AzureRM Response for https://management.azure.com/subscriptions//resourceGroups/acctestRG-211129104546431506/providers/Microsoft.Sql/servers/acctestsqlserver211129104546431506/databases/acctestdb211129104546431506?api-version=2014-04-01:
HTTP/2.0 504 Gateway Timeout
Content-Length: 141
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Mon, 29 Nov 2021 09:51:31 GMT
Expires: -1
Pragma: no-cache
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: fbcfa19c-ed4a-d048-f9a0-ace304659c50
X-Ms-Failure-Cause: service
X-Ms-Request-Id: 30eb61c1-58d5-4e3d-80a4-906a08961189
X-Ms-Routing-Request-Id: WESTEUROPE:20211129T095131Z:30eb61c1-58d5-4e3d-80a4-906a08961189

{"error":{"code":"GatewayTimeout","message":"The gateway did not receive a response from 'Microsoft.Sql' within the specified time period."}}
2021/11/29 10:51:59 [DEBUG] AzureRM Request:
PUT /subscriptions//resourceGroups/acctestRG-211129104546431506/providers/Microsoft.Sql/servers/acctestsqlserver211129104546431506/databases/acctestdb211129104546431506?api-version=2014-04-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.17.2 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v59.2.0 sql/2017-03-01-preview HashiCorp Terraform/1.0.10 (+https://www.terraform.io) Terraform Plugin SDK/2.8.0 terraform-provider-azurerm/acc pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 315
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: fbcfa19c-ed4a-d048-f9a0-ace304659c50
Accept-Encoding: gzip

{"location":"westeurope","properties":{"collation":"SQL_Latin1_General_CP1_CI_AS","createMode":"Default","edition":"Premium","maxSizeBytes":"1073741824","readScale":"Disabled","requestedServiceObjectiveId":"7203483a-c4fb-4304-9e9f-17c71c904f5d","requestedServiceObjectiveName":"P1","zoneRedundant":false},"tags":{}}
2021/11/29 10:51:59 [DEBUG] AzureRM Response for https://management.azure.com/subscriptions//resourceGroups/acctestRG-211129104546431506/providers/Microsoft.Sql/servers/acctestsqlserver211129104546431506/databases/acctestdb211129104546431506?api-version=2014-04-01:
HTTP/2.0 400 Bad Request
Content-Length: 679
Cache-Control: no-store, no-cache
Content-Type: application/json
Dataserviceversion: 3.0;
Date: Mon, 29 Nov 2021 09:52:01 GMT
Preference-Applied: return-content
Server: Microsoft-HTTPAPI/2.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: fbcfa19c-ed4a-d048-f9a0-ace304659c50
X-Ms-Ratelimit-Remaining-Subscription-Writes: 1198
X-Ms-Request-Id: 0ab302ab-83a1-4b0b-bcfc-026c09f2baea
X-Ms-Routing-Request-Id: WESTEUROPE:20211129T095202Z:8f34a8fc-c986-498e-b71a-d7d1fc55604e

{"code":"40802","message":"A service objective assignment on server \u0027acctestsqlserver211129104546431506\u0027 and database \u0027acctestdb211129104546431506\u0027 is already in progress. Please wait until the service objective assignment state for the database is marked as \u0027Completed\u0027.","target":null,"details":[{"code":"40802","message":"A service objective assignment on server \u0027acctestsqlserver211129104546431506\u0027 and database \u0027acctestdb211129104546431506\u0027 is already in progress. Please wait until the service objective assignment state for the database is marked as \u0027Completed\u0027.","target":null,"severity":"16"}],"innererror":[]}
```
It seems the time-out is triggering some action which blocks subsequent requests. GatewayTimeout is usually an indicator of bad error handling server side.

## Linked issues
- Similar to #16838, except that I don't know how to circumvent this one (yet).
- It causes failures in the acceptance tests for `azurerm`, which can be triggered by running `git clone https://github.com/hashicorp/terraform-provider-azurerm.git && cd terraform-provider-azurerm && go install && make acctests SERVICE='sql' TESTARGS='-run=TestAccSqlDatabase_zoneRedundant'`

Contributor guide

Open the contributing guide

Research direction

Start by running the linked SQL acceptance-test command for TestAccSqlDatabase_zoneRedundant and review the reported PUT requests and responses for Microsoft.Sql databases using api-version=2014-04-01. Compare the timeout and subsequent 40802 response with similar issue #16838; done means the failure is reproducible and its handling or specification-level cause is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, openapi, sql
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.