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

DynamoDB Create fails to return on error #1271

Closed
grubernaut opened this issue May 15, 2017 · 6 comments
Closed

DynamoDB Create fails to return on error #1271

grubernaut opened this issue May 15, 2017 · 6 comments
Labels
service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@grubernaut
Copy link

Version of AWS SDK for Go?

v1.8.21

Version of Go (go version)?

go1.8.1

What issue did you see?

When calling CreateTable() with correct parameters, the function fails to return if the request would exceed the subscriber limit on the number of tables allowed to be created.
We call CreateTable() here: https://github.com/hashicorp/terraform/blob/master/builtin/providers/aws/resource_aws_dynamodb_table.go#L321, but the function never returns the 400 as expected. Is there a wait inside the request function that doesn't return within ~10s?

Expected that the 400 error would be returned so we can handle the error, but the error is never returned.

2017/05/15 10:58:21 [DEBUG] plugin: terraform: aws-provider (internal) 2017/05/15 10:58:21 [DEBUG] [aws-sdk-go] DEBUG: Request dynamodb/CreateTable Details:                                 
2017/05/15 10:58:21 [DEBUG] plugin: terraform: ---[ REQUEST POST-SIGN ]-----------------------------                                                                                         
2017/05/15 10:58:21 [DEBUG] plugin: terraform: POST / HTTP/1.1                                                                                                                               
2017/05/15 10:58:21 [DEBUG] plugin: terraform: Host: dynamodb.us-west-2.amazonaws.com                                                                                                        
2017/05/15 10:58:21 [DEBUG] plugin: terraform: User-Agent: aws-sdk-go/1.8.21 (go1.8.1; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.9.6-dev                                               
2017/05/15 10:58:21 [DEBUG] plugin: terraform: Content-Length: 222                                                                                                                           
2017/05/15 10:58:21 [DEBUG] plugin: terraform: Accept-Encoding: identity                                                                                                                     
2017/05/15 10:58:21 [DEBUG] plugin: terraform: Authorization: (Redacted)                                                             
2017/05/15 10:58:21 [DEBUG] plugin: terraform: Content-Type: application/x-amz-json-1.0                                                                                                      
2017/05/15 10:58:21 [DEBUG] plugin: terraform: X-Amz-Date: 20170515T145821Z                                                                                                                  
2017/05/15 10:58:21 [DEBUG] plugin: terraform: X-Amz-Target: DynamoDB_20120810.CreateTable                                                                                                   
2017/05/15 10:58:21 [DEBUG] plugin: terraform:                                                                                                                                               
2017/05/15 10:58:21 [DEBUG] plugin: terraform: {"AttributeDefinitions":[{"AttributeName":"id","AttributeType":"S"}],"KeySchema":[{"AttributeName":"id","KeyType":"HASH"}],"ProvisionedThrough
put":{"ReadCapacityUnits":5,"WriteCapacityUnits":5},"TableName":"over-cap-test"}                                                                                                             
2017/05/15 10:58:21 [DEBUG] plugin: terraform: -----------------------------------------------------                                                                                         
2017/05/15 10:58:22 [DEBUG] plugin: terraform: aws-provider (internal) 2017/05/15 10:58:22 [DEBUG] [aws-sdk-go] DEBUG: Response dynamodb/CreateTable Details:                                
2017/05/15 10:58:22 [DEBUG] plugin: terraform: ---[ RESPONSE ]--------------------------------------                                                                                         
2017/05/15 10:58:22 [DEBUG] plugin: terraform: HTTP/1.1 400 Bad Request                                                                                                                      
2017/05/15 10:58:22 [DEBUG] plugin: terraform: Connection: close                                                                                                                             
2017/05/15 10:58:22 [DEBUG] plugin: terraform: Content-Length: 153                                                                                                                           
2017/05/15 10:58:22 [DEBUG] plugin: terraform: Content-Type: application/x-amz-json-1.0                                                                                                      
2017/05/15 10:58:22 [DEBUG] plugin: terraform: Date: Mon, 15 May 2017 14:58:03 GMT                                                                                                           
2017/05/15 10:58:22 [DEBUG] plugin: terraform: Server: Server                                                                                                                                
2017/05/15 10:58:22 [DEBUG] plugin: terraform: X-Amz-Crc32: 2060884299                                                                                                                       
2017/05/15 10:58:22 [DEBUG] plugin: terraform: X-Amzn-Requestid: NDUFTLU30MM8AUMH3AANV73P8FVV4KQNSO5AEMVJF66Q9ASUAAJG                                                                        
2017/05/15 10:58:22 [DEBUG] plugin: terraform:
2017/05/15 10:58:22 [DEBUG] plugin: terraform: {"__type":"com.amazonaws.dynamodb.v20120810#LimitExceededException","message":"Subscriber limit exceeded: There is a limit of 256 tables per s
ubscriber"}

However, I can see that the Create request is retried, instead of returning the error via subsequent POST/RESPONSE debug statements that include the same 400 error.

Steps to reproduce

  • Create 255 DynamoDB tables
  • Attempt to create another table

Thanks!

@jasdel
Copy link
Contributor

jasdel commented May 15, 2017

Thanks for creating this issue @grubernaut I'm investigating this issue. You're correct that the SDK is treating the error as a throttling which is causing the significant delay before failure. This error shouldn't be treated as a error.

@jasdel jasdel added the bug This issue is a bug. label May 15, 2017
@jasdel
Copy link
Contributor

jasdel commented May 15, 2017

After a bit of investigation it looks like this exception is returned for both throttling rate limiting conditions as well as total number of tables crated reaches a limit. I think this needs more investigation into how the SDK should handle this error, because I don't think the SDK knows if it can or cannot retry this request without parsing the error message. Paring the error message would be fragile. I'll reach out to the DynamoDB service team to get a better idea how this error should be handled.

@jasdel jasdel added service-api This issue is due to a problem in a service API, not the SDK implementation. and removed bug This issue is a bug. labels May 15, 2017
@grubernaut
Copy link
Author

Hey @jasdel, thanks for the responses!

Just to note, we're also seeing this issue with Kinesis Firehose Delivery Streams, as noted here: hashicorp/terraform#11143.

If there's any other information or debug output needed, please let me know. Thanks for the help on this one :)

jasdel added a commit to jasdel/aws-sdk-go that referenced this issue May 16, 2017
The LimitExceededException error code should not be treated as a
throttling condition. This error code implies that resources are
exhausted or too many tasks are being attempted at once. The SDK does
not have the information it needs to distinguish between the resources
exhausted and too many tasks attempted at once.

This logic is best implemented by user applications as they will have
the most context about what is being attempted.

To add custom retry with this error code a custom implementation of the
"request.Retryer" interface should be used.

Fix aws#1271
@jasdel
Copy link
Contributor

jasdel commented May 16, 2017

Hi @grubernaut I created #1276 to address this issue by removing LimitExceededException from the list of error codes that should be throttled.

Since this throttling on +10 create/delete/update concurrent DynamoDB tasks could still fail due to the limit exceeded exception I do not think this would be a breaking change for users as they would need to have logic handling the error code anyways.

jasdel added a commit that referenced this issue May 16, 2017
…1276)

The LimitExceededException error code should not be treated as a
throttling condition. This error code implies that resources are
exhausted or too many tasks are being attempted at once. The SDK does
not have the information it needs to distinguish between the resources
exhausted and too many tasks attempted at once.

This logic is best implemented by user applications as they will have
the most context about what is being attempted.

To add custom retry with this error code a custom implementation of the
request.Retryer interface should be used.

Fix #1271
@grubernaut
Copy link
Author

Works perfectly, thanks for the quick turnaround on this @jasdel. 🎉

@jasdel
Copy link
Contributor

jasdel commented May 17, 2017

Thanks for the update @grubernaut Let us know if you find any additional cases, or have feedback on the SDK!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants