@@ -37,12 +37,12 @@ use graph::data::graphql::TypeExt as _;
3737use graph:: data:: query:: Trace ;
3838use graph:: data:: value:: Word ;
3939use graph:: data_source:: CausalityRegion ;
40- use graph:: internal_error;
4140use graph:: prelude:: { q, EntityQuery , StopwatchMetrics , ENV_VARS } ;
4241use graph:: schema:: {
4342 EntityKey , EntityType , Field , FulltextConfig , FulltextDefinition , InputSchema ,
4443} ;
4544use graph:: slog:: warn;
45+ use graph:: { internal_error, tokio} ;
4646use index:: IndexList ;
4747use inflector:: Inflector ;
4848use itertools:: Itertools ;
@@ -1087,13 +1087,13 @@ impl Layout {
10871087 /// This is tied closely to how the `LayoutCache` works and called from
10881088 /// it right after creating a `Layout`, and periodically to update the
10891089 /// `Layout` in case changes were made
1090- fn refresh (
1090+ async fn refresh (
10911091 self : Arc < Self > ,
10921092 conn : & mut PgConnection ,
10931093 site : Arc < Site > ,
10941094 ) -> Result < Arc < Self > , StoreError > {
10951095 let account_like = crate :: catalog:: account_like ( conn, & self . site ) ?;
1096- let history_blocks = deployment:: history_blocks ( conn, & self . site ) ?;
1096+ let history_blocks = deployment:: history_blocks ( conn, & self . site ) . await ?;
10971097
10981098 let is_account_like = { |table : & Table | account_like. contains ( table. name . as_str ( ) ) } ;
10991099
@@ -1750,7 +1750,7 @@ pub struct LayoutCache {
17501750 ttl : Duration ,
17511751 /// Use this so that we only refresh one layout at any given time to
17521752 /// avoid refreshing the same layout multiple times
1753- refresh : Mutex < ( ) > ,
1753+ refresh : tokio :: sync :: Mutex < ( ) > ,
17541754 last_sweep : Mutex < Instant > ,
17551755}
17561756
@@ -1759,7 +1759,7 @@ impl LayoutCache {
17591759 Self {
17601760 entries : Mutex :: new ( HashMap :: new ( ) ) ,
17611761 ttl,
1762- refresh : Mutex :: new ( ( ) ) ,
1762+ refresh : tokio :: sync :: Mutex :: new ( ( ) ) ,
17631763 last_sweep : Mutex :: new ( Instant :: now ( ) ) ,
17641764 }
17651765 }
@@ -1770,7 +1770,7 @@ impl LayoutCache {
17701770 deployment:: entities_with_causality_region ( conn, site. id , & subgraph_schema) ?;
17711771 let catalog = Catalog :: load ( conn, site. clone ( ) , use_bytea_prefix, has_causality_region) ?;
17721772 let layout = Arc :: new ( Layout :: new ( site. clone ( ) , & subgraph_schema, catalog) ?) ;
1773- layout. refresh ( conn, site)
1773+ layout. refresh ( conn, site) . await
17741774 }
17751775
17761776 fn cache ( & self , layout : Arc < Layout > ) {
@@ -1822,7 +1822,7 @@ impl LayoutCache {
18221822 if refresh. is_err ( ) {
18231823 value
18241824 } else {
1825- self . refresh ( logger, conn, site, value)
1825+ self . refresh ( logger, conn, site, value) . await
18261826 }
18271827 }
18281828 }
@@ -1836,14 +1836,14 @@ impl LayoutCache {
18361836 Ok ( layout)
18371837 }
18381838
1839- fn refresh (
1839+ async fn refresh (
18401840 & self ,
18411841 logger : & Logger ,
18421842 conn : & mut PgConnection ,
18431843 site : Arc < Site > ,
18441844 value : Arc < Layout > ,
18451845 ) -> Arc < Layout > {
1846- match value. cheap_clone ( ) . refresh ( conn, site) {
1846+ match value. cheap_clone ( ) . refresh ( conn, site) . await {
18471847 Err ( e) => {
18481848 warn ! (
18491849 logger,
0 commit comments