File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ export class DefinedSchemas {
88 constructor ( localSchemas , config ) {
99 this . config = Config . get ( config . appId ) ;
1010 this . localSchemas = localSchemas ;
11+ this . retries = 0 ;
12+ this . maxRetries = 3 ;
1113 }
1214
1315 // Simulate save like the SDK
@@ -58,8 +60,18 @@ export class DefinedSchemas {
5860 await Promise . all ( this . localSchemas . map ( async localSchema => this . saveOrUpdate ( localSchema ) ) ) ;
5961 await this . enforceCLPForNonProvidedClass ( ) ;
6062 } catch ( e ) {
61- logger . error ( e ) ;
62- if ( process . env . NODE_ENV === 'production' ) process . exit ( 1 ) ;
63+ if ( this . retries <= this . maxRetries ) {
64+ this . retries ++ ;
65+ // first retry 1sec, 2sec, 3sec total 6sec retry sequence
66+ // retry will only happen in case of deploying multi parse server instance
67+ // at the same time
68+ // modern systems like k8 avoid this by doing rolling updates
69+ await new Promise ( resolve => setTimeout ( resolve , 1000 * this . retries ) ) ;
70+ await this . execute ( ) ;
71+ } else {
72+ logger . error ( e ) ;
73+ if ( process . env . NODE_ENV === 'production' ) process . exit ( 1 ) ;
74+ }
6375 }
6476 }
6577
You can’t perform that action at this time.
0 commit comments