awslabs/dynamodb-cross-region-library

Creating replication group silently fails if non-NEW_AND_OLD_IMAGES stream exists

ebroder opened this issue · 3 comments

In DynamoDBReplicationUtilities.createTableIfNotExists, the current stream specification is compared against the desired stream specification, and the table's config is updated if they don't match.

This works fine if streams aren't enabled in the first place. However, if streams are already enabled, but the stream type is something other than NEW_AND_OLD_IMAGES, the UpdateTable call fails with a ResourceInUse exception.

As a side note, this was pretty difficult to debug, because the resulting exception isn't actually printed - you just get the following log line in CloudWatch:

2015-09-06 12:37:41,108 ERROR com.amazonaws.services.dynamodbv2.replication.coordinator.state.DynamoDBReplicationGroupCreationStarted - Unable to create table for replication member with ARN: <arn>
jseed commented

Just to verify that this is, in fact, the cause of the problem...
From the UpdateTableRequest documentation for withStreamSpecification:

You will receive a ResourceInUseException if you attempt to enable a stream on a table that already has a stream, or if you attempt to disable a stream on a table which does not have a stream.

Seems like the fix is disabling the stream before changing the view type when enabled and something other than NEW_AND_OLD_IMAGES

Right, although I think the larger issue is that this fact is not surfaced to the user via the replication console, and is barely surfaced at all via those CloudWatch logs.

Hi,

As a part of the improvement process for cross-region replication library, we have refactored the library completely and released an updated version. As a result, the previous version involving multiple components has been deprecated and I suggest you use the new libraries as command-line tools instead. The error referred to here should surface as an error when attempting to execute via command line.

All the code has also been refactored down to the fundamental components only, stripping away other complicated and unnecessary dependencies. This should make the library much easier to understand, and a lot less cumbersome to manage as a client-side solution.

Thank you!