File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -161,11 +161,12 @@ impl Metrics {
161161 }
162162}
163163
164- pub fn run_database_metrics_work ( db : Postgres ) {
164+ pub fn run_database_metrics_work ( db : Postgres , run_analyze : bool ) {
165165 let span = tracing:: info_span!( "database_metrics" ) ;
166- // Spawn the task for updating large table statistics
167- tokio:: spawn ( update_large_tables_stats ( db. clone ( ) ) . instrument ( span. clone ( ) ) ) ;
168-
166+ if run_analyze {
167+ // Spawn the task for updating large table statistics
168+ tokio:: spawn ( update_large_tables_stats ( db. clone ( ) ) . instrument ( span. clone ( ) ) ) ;
169+ }
169170 // Spawn the task for database metrics
170171 tokio:: task:: spawn ( database_metrics ( db) . instrument ( span) ) ;
171172}
Original file line number Diff line number Diff line change @@ -171,17 +171,22 @@ pub async fn run(args: Arguments, shutdown_controller: ShutdownController) {
171171 . await
172172 . unwrap ( ) ;
173173
174- let db_read = if let Some ( db_read_url) = args. db_read_url
174+ let ( db_read, run_analyze ) = if let Some ( db_read_url) = args. db_read_url
175175 && args. db_write_url != db_read_url
176176 {
177- Postgres :: new ( db_read_url. as_str ( ) , args. insert_batch_size )
178- . await
179- . expect ( "failed to create read replica database" )
177+ (
178+ Postgres :: new ( db_read_url. as_str ( ) , args. insert_batch_size )
179+ . await
180+ . expect ( "failed to create read replica database" ) ,
181+ // If the DB is in read-only mode, running ANALYZE is not possible and will trigger and
182+ // error https://www.postgresql.org/docs/current/hot-standby.html
183+ false ,
184+ )
180185 } else {
181- db_write. clone ( )
186+ ( db_write. clone ( ) , true )
182187 } ;
183188
184- crate :: database:: run_database_metrics_work ( db_read. clone ( ) ) ;
189+ crate :: database:: run_database_metrics_work ( db_read. clone ( ) , run_analyze ) ;
185190
186191 let http_factory = HttpClientFactory :: new ( & args. http_client ) ;
187192 let web3 = shared:: ethrpc:: web3 (
You can’t perform that action at this time.
0 commit comments