@@ -67,11 +67,11 @@ public function getPostgresDriver()
6767    {
6868        try  {
6969            $ pdo  = new  \PDO ('pgsql:host=localhost;dbname=oauth2_server_php ' , 'postgres ' );
70+ 
71+             return  $ pdo ;
7072        } catch  (\PDOException   $ e ) {
7173            $ this  ->postgres  = new  NullStorage ('Postgres ' , $ e ->getMessage ());
7274        }
73- 
74-         return  $ pdo ;
7575    }
7676
7777    public  function  getMemoryStorage ()
@@ -430,7 +430,9 @@ public function getDynamoDbStorage()
430430                    if  ($ build_id  = $ this  ->getEnvVar ('TRAVIS_JOB_NUMBER ' )) {
431431                        $ prefix  = sprintf ('build_%s_ ' , $ build_id );
432432                    } else  {
433-                         $ this  ->deleteDynamoDb ($ client , $ prefix , true );
433+                         if  (!$ this  ->deleteDynamoDb ($ client , $ prefix , true )) {
434+                             return  $ this  ->dynamodb  = new  NullStorage ('DynamoDb ' , 'Timed out while waiting for DynamoDB deletion (30 seconds) ' );
435+                         }
434436                    }
435437                    $ this  ->createDynamoDb ($ client , $ prefix );
436438                    $ this  ->populateDynamoDb ($ client , $ prefix );
@@ -498,6 +500,7 @@ private function deleteDynamoDb(\Aws\DynamoDb\DynamoDbClient $client, $prefix =
498500
499501        // Wait for deleting 
500502        if  ($ waitForDeletion ) {
503+             $ retries  = 5 ;
501504            $ nbTableDeleted  = 0 ;
502505            while  ($ nbTableDeleted  != $ nbTables ) {
503506                $ nbTableDeleted  = 0 ;
@@ -510,10 +513,18 @@ private function deleteDynamoDb(\Aws\DynamoDb\DynamoDbClient $client, $prefix =
510513                    }
511514                }
512515                if  ($ nbTableDeleted  != $ nbTables ) {
513-                     sleep (1 );
516+                     if  ($ retries  < 0 ) {
517+                         // we are tired of waiting 
518+                         return  false ;
519+                     }
520+                     sleep (5 );
521+                     echo  "Sleeping 5 seconds for DynamoDB ( $ retries more retries)... \n" ;
522+                     $ retries --;
514523                }
515524            }
516525        }
526+ 
527+         return  true ;
517528    }
518529
519530    private  function  createDynamoDb (\Aws \DynamoDb \DynamoDbClient   $ client , $ prefix  = null )
0 commit comments