@@ -357,7 +357,9 @@ class SystemStore extends EventEmitter {
357
357
this . START_REFRESH_THRESHOLD = 10 * 60 * 1000 ;
358
358
this . FORCE_REFRESH_THRESHOLD = 60 * 60 * 1000 ;
359
359
this . SYSTEM_STORE_LOAD_CONCURRENCY = config . SYSTEM_STORE_LOAD_CONCURRENCY || 5 ;
360
- this . source = config . SYSTEM_STORE_SOURCE . toLocaleLowerCase ( ) === 'core' ? SOURCE . CORE : SOURCE . DB ;
360
+ //load from core if enabled and this is an endpoint
361
+ const is_endpoint = process . env . HOSTNAME && process . env . HOSTNAME . indexOf ( "endpoint" ) ;
362
+ this . source = ( config . SYSTEM_STORE_SOURCE . toLowerCase ( ) === 'core' && is_endpoint ) ? SOURCE . CORE : SOURCE . DB ;
361
363
dbg . log0 ( "system store source is" , this . source ) ;
362
364
this . _load_serial = new semaphore . Semaphore ( 1 , { warning_timeout : this . START_REFRESH_THRESHOLD } ) ;
363
365
for ( const col of COLLECTIONS ) {
@@ -671,8 +673,21 @@ class SystemStore extends EventEmitter {
671
673
method_api : 'server_inter_process_api' ,
672
674
method_name : 'load_system_store' ,
673
675
target : '' ,
674
- request_params : { since : last_update }
676
+ request_params : { since : last_update , load_from_core_step : 'core' }
675
677
} ) ;
678
+
679
+ //if endpoints are loading system store from core, we need to wait until
680
+ //above publish_to_cluster() will update core's in-memory db.
681
+ //the next publist_to_cluster() will make endpoints load the updated
682
+ //system store from core
683
+ if ( config . SYSTEM_STORE_SOURCE . toLowerCase ( ) === 'core' ) {
684
+ await server_rpc . client . redirector . publish_to_cluster ( {
685
+ method_api : 'server_inter_process_api' ,
686
+ method_name : 'load_system_store' ,
687
+ target : '' ,
688
+ request_params : { since : last_update , load_from_core_step : 'endpoint' }
689
+ } ) ;
690
+ }
676
691
}
677
692
}
678
693
}
0 commit comments