You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(startup): decouple precache and mempool sync from server startup
After a pod/node restart, electrs refused to listen on any port until it
had serially completed (1) the popular-scripts precache and (2) a full
initial mempool sync over JSONRPC. On a congested mainnet mempool this
kept instances unready for 15-30+ minutes even though the chain index
was fully usable within seconds (measured: 17 min total, of which 15 min
was mempool sync).
- Run --precache-scripts in a background thread; it is pure cache
warming and never affects correctness. The file is still read upfront
to fail fast on a bad path.
- Add --serve-during-mempool-sync (default off, no behavior change):
start the REST/Electrum servers before the initial mempool sync.
Chain-based queries are fully correct during the sync; mempool-derived
data is incomplete until the first full sync completes.
- Add GET /health/ready returning {chain_synced, mempool_synced} with
200 once the initial mempool sync has completed and 503 before that,
so load balancers / readiness probes can keep early-serving instances
out of rotation. Deployments enabling --serve-during-mempool-sync MUST
switch readiness probes from a TCP check to this endpoint.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: src/config.rs
+11Lines changed: 11 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,11 @@ pub struct Config {
38
38
pubindex_unspendables:bool,
39
39
pubcors:Option<String>,
40
40
pubprecache_scripts:Option<String>,
41
+
/// Start the REST and Electrum servers before the initial mempool sync completes.
42
+
/// Chain-based queries are fully correct during the sync; mempool-derived data is
43
+
/// incomplete until /health/ready reports mempool_synced=true, so readiness probes
44
+
/// must use that endpoint instead of a TCP check when this is enabled.
45
+
pubserve_during_mempool_sync:bool,
41
46
pubutxos_limit:usize,
42
47
pubelectrum_txs_limit:usize,
43
48
pubelectrum_banner:String,
@@ -215,6 +220,11 @@ impl Config {
215
220
.help("Path to file with list of scripts to pre-cache")
216
221
.takes_value(true)
217
222
)
223
+
.arg(
224
+
Arg::with_name("serve_during_mempool_sync")
225
+
.long("serve-during-mempool-sync")
226
+
.help("Start the REST/Electrum servers before the initial mempool sync completes. Requires readiness checks to use /health/ready instead of a TCP probe.")
0 commit comments