1
votes

I am using DynamoDB. I do scan operations from the app. Everything works perfect. After sometime, the response is coming as nil. But I am not receiving any exceptions. I enabled verbose logging using,

[AmazonLogger verboseLogging];

If the verbose logging is enabled, I can see some logs like,

"__type":"com.amazonaws.dynamodb.v20111205#ProvisionedThroughputExceededException","message":"The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API"

My code looks like this,

@try {
    DynamoDBScanRequest *request = /* Create request */;
    DynamoDBScanResponse *response = [[AmazonClientManager ddb] scan:request];
    /* 
     * response is nil if the provisioning throughput is exceeded 
     * and the all retries are over
     */
    ALog(@"Response: %@", response); 
    NSMutableArray *array = response.items;
    return array;
} @catch (NSException *exception) {
    /* 
     * I am expecting the  ProvisionedThroughputExceededException 
     * to be thrown here. But its not throwing here. Instead I get the response
     * as nil above.
     */
    ALog(@"Exception: %@", exception);
    return nil;
}

Am I doing it correct? Could someone help me please?

Thanks.

Edit: Could anyone give me a rough idea of how much throughput (both read/write) capacity to set for a QuestionAnswer table, with almost 10 fields like TopicID, QuestionID, Question, Answer, AskedAt, RepliedAt, QuestionType etc.,? Thanks.

1
DynamoDB is priced based on the amount of provisioned throughput you have configured, you are accessing it more frequently than your setup has indicated and you're being throttled. You need to consider if you actually need to scan the table, a scan will inspect the entire table which results in high throughput, if this is the first NoSQL DB you've used you should do some investigation into how best to use them, you can't just perform ad hoc queries like RDB, they're expensive in terms of time and resources. Consider managing indexes that would allow explicit gets as separate tables. - codeghost
Thanks. You mean there is no way I will get the exception thrown to the @catch block if I use Scan? - EmptyStack
Do you see the earlier Response ALog messages, to be sure your logging is configured correctly? If you put a break in the catch does it trigger before you get nil or is nil definitely being returned from the try block? I've not used the AWS iOS SDK for Dynamo, but have had experience of some of their other APIs not always performing as expected, so if you're never entering your catch block it may be that their sdk is swallowing the exception earlier. Could be worth trying to add a global exception handler to see if anything crops up there. - codeghost
I am sure ALog works good. It does log some other exceptions. But in the above try/catch block, I tried putting breakpoints inside catch block. But it never gets into it. I will try the global exception handler. Thanks for your time. I really appreciate it. - EmptyStack
No problem, may be worth raising the issue on the AWS forums to get their opinion too. - codeghost

1 Answers

4
votes

I've tried a scan request with more read capacity units than provisioned, and I got AmazonClientException with a generic message: "Unknown error occurred." We are working on a fix, and the next version should correctly return DynamoDBProvisionedThroughputExceededException in the described situation.

You said the response becomes nil, but I was not able to reproduce the issue. Do you call [AmazonErrorHandler shouldNotThrowExceptions] to turn off the exceptions? When this option is turned on, the SDK won't throw AmazonClientException and AmazonServiceException. It is also possible that you are using an older version of the SDK. Please try 1.4.4 and see if you get the exception. It is suboptimal, but at least you should be able to catch an exception when something goes wrong.