HENNGE / aiodynamo

Asynchronous, fast, pythonic DynamoDB Client
https://aiodynamo.readthedocs.io/
Other
69 stars 20 forks source link

Surprising behaviour in `Client.table_exists` #138

Open darylweir opened 1 year ago

darylweir commented 1 year ago

We use Table.exists as part of a health check for the containers in our application, which in turn calls Client.table_exists. Today we had a short outage when all health checks began failing. It turned out the Dynamo table had entered UPDATING status.

The implementation does the following:

async def table_exists(self, name: TableName) -> bool:
        try:
            description = await self.describe_table(name)
        except TableNotFound:
            return False

        return description.status is TableStatus.active

This feels like a bug to us: UPDATING is a valid state while a variety of operations are being applied to the table. So the code should do return description.status in [TableStatus.active, TableStatus.updating].

Thoughts?

ojii commented 1 year ago

@darylweir thank you for this report. I agree it would make sense for table_exists to also allow .updating. But there's probably also a use case (eg our test suite) for table_active that mirrors the behavior of the current table_exists. I'd be happy to accept a PR that improves this situation.