diff --git a/localstack-core/localstack/services/dynamodb/server.py b/localstack-core/localstack/services/dynamodb/server.py index 68dac757b9d82..2e41477749762 100644 --- a/localstack-core/localstack/services/dynamodb/server.py +++ b/localstack-core/localstack/services/dynamodb/server.py @@ -62,7 +62,6 @@ def __init__( self.db_path = None if self.db_path: - mkdir(self.db_path) self.db_path = os.path.abspath(self.db_path) self.heap_size = config.DYNAMODB_HEAP_SIZE @@ -80,12 +79,18 @@ def get() -> "DynamodbServer": def start_dynamodb(self) -> bool: """Start the DynamoDB server.""" + # For the v2 provider, the DynamodbServer has been made a singleton. Yet, the Server abstraction is modelled + # after threading.Thread, where Start -> Stop -> Start is not allowed. This flow happens during state resets. + # The following is a workaround that permits this flow + self._started.clear() + self._stopped.clear() + # Note: when starting the server, we had a flag for wiping the assets directory before the actual start. # This behavior was needed in some particular cases: # - pod load with some assets already lying in the asset folder # - ... # The cleaning is now done via the reset endpoint - self._stopped.clear() + mkdir(self.db_path) started = self.start() self.wait_for_dynamodb() return started