@@ -82,33 +82,41 @@ private static function createTableIfNecessary()
8282 return ; // table already exists
8383 } catch (\Exception $ e ) {
8484 }
85- self ::$ dynamoDbClient ->createTable (array (
86- 'TableName ' => self ::TABLE_NAME ,
87- 'AttributeDefinitions ' => array (
88- array (
89- 'AttributeName ' => 'namespace ' ,
90- 'AttributeType ' => 'S '
91- ),
92- array (
93- 'AttributeName ' => 'key ' ,
94- 'AttributeType ' => 'S '
95- )
96- ),
97- 'KeySchema ' => array (
98- array (
99- 'AttributeName ' => 'namespace ' ,
100- 'KeyType ' => 'HASH '
101- ),
102- array (
103- 'AttributeName ' => 'key ' ,
104- 'KeyType ' => 'RANGE '
105- )
106- ),
107- 'ProvisionedThroughput ' => array (
108- 'ReadCapacityUnits ' => 1 ,
109- 'WriteCapacityUnits ' => 1
110- )
111- ));
85+ while (true ) {
86+ // We may need to retry this because in the CI build, the local DynamoDB may not have finished starting yet.
87+ try {
88+ self ::$ dynamoDbClient ->createTable (array (
89+ 'TableName ' => self ::TABLE_NAME ,
90+ 'AttributeDefinitions ' => array (
91+ array (
92+ 'AttributeName ' => 'namespace ' ,
93+ 'AttributeType ' => 'S '
94+ ),
95+ array (
96+ 'AttributeName ' => 'key ' ,
97+ 'AttributeType ' => 'S '
98+ )
99+ ),
100+ 'KeySchema ' => array (
101+ array (
102+ 'AttributeName ' => 'namespace ' ,
103+ 'KeyType ' => 'HASH '
104+ ),
105+ array (
106+ 'AttributeName ' => 'key ' ,
107+ 'KeyType ' => 'RANGE '
108+ )
109+ ),
110+ 'ProvisionedThroughput ' => array (
111+ 'ReadCapacityUnits ' => 1 ,
112+ 'WriteCapacityUnits ' => 1
113+ )
114+ ));
115+ break ;
116+ } catch (\Exception $ e ) {
117+ sleep (1 );
118+ }
119+ }
112120 while (true ) { // table may not be available immediately
113121 try {
114122 self ::$ dynamoDbClient ->describeTable (array ('TableName ' => self ::TABLE_NAME ));
0 commit comments