awslabs / dynamodb-continuous-backup

Continuous backup automation for Amazon DynamoDB
Apache License 2.0
185 stars 27 forks source link

setup_existing_tables.py::resolve_table_list() does not return all tables #16

Open hoanngu opened 7 years ago

hoanngu commented 7 years ago

I have an account where running the provision_tables.py script (which uses setup_existing_tables.py) only provisions 6 of the 10 DynamoDB tables on the account. Possibly an issue with the paging in the dynamo_client.list_tables() function as removing the ExclusiveStartTableName parameter resolves this issue for this account.

IanMeyers commented 7 years ago

Can you please check that you have version committed in 69782a2141682fdf8254fa1d1017a362dec9e3c1? This fixed an issue that had been seen previously.

IanMeyers commented 7 years ago

Actually please resync to https://github.com/awslabs/dynamodb-continuous-backup/commit/2b262aba642678eb1e47c26e8dbaac93618bef07, there may have been an issue after page 1.

hoanngu commented 7 years ago

Synced to latest 2b262aba642678eb1e47c26e8dbaac93618bef07, but the while() in resolve_table_list() now results in an infinite loop. Thanks for taking a look at this.

IanMeyers commented 7 years ago

Sorry - reverted that - please re-sync and re-run?

hoanngu commented 7 years ago

Synced to latest ee9cc5ccdb3f0c0b28a03cbf5c08f3fe995cc0f4. Fixed the loop, but list_tables() still only returns 6 of the 10 tables. May be an issue with Boto's list_tables() function as it returns only the same 6 tables whenever the ExclusiveStartTableName parameter is populated. This does not appear to be an issue with dynamodb-continuous-backup's pagination as it works fine if, for instance, one sets Limit=2; it will correctly do 3 separate calls to return all 6.

Interim solution for this account appears to be calling list_tables() with no ExclusiveStartTableName parameter and only specifying ExclusiveStartTableName when LastEvaluatedTableName is populated. Using botocore 2.44.0 and boto3 1.4.2

IanMeyers commented 7 years ago

OK - I have boto3 v 1.4.7, and botocore 1.7.3. This is what I did:

>>> import boto3
>>> print boto3.__version__
1.4.7
>>> import botocore
>>> print botocore.__version__
1.7.3
>>> dynamo_client = boto3.client('dynamodb', region_name='eu-west-1')
>>> lt = dynamo_client.list_tables()
>>> v = 0;
>>> for x in lt['TableNames']:
...     v+=1
...
>>> print v
36

So as you say, I can see 36 tables with no filter. Now I force pagination which excludes the first table:

>>> lt = dynamo_client.list_tables(ExclusiveStartTableName='AutoscalingCreateRoute53Entries')
>>> v = 0;
>>> for x in lt['TableNames']:
...     v+= 1
...
>>> print v
35

Now exclude everything except the last table:

>>> lt = dynamo_client.list_tables(ExclusiveStartTableName='kinesisBridge')
>>> v = 0;
>>> for x in lt['TableNames']:
...     v+= 1
...
>>> print v
1

I'm not really able to reproduce. Can you tell me what you see when you run the same test?