Repository: lightningnetwork/lnd
Pull request #4933 (2021-01-20 08:57:53)

routing: delay initial zombie prune by 30 sec
Since zombie pruning can be very slow on some devices (e.g. mobile) it
would stall lnd startup. Since it is not essential for pruning to be
finished for lnd to be functional, we instead delay the initial prune by
30 seconds.

Note that we could also wait for the graphPruneInterval to tick, but
since this is by default 2 hours, it is unlikely that a mobile app will
ever be open that long.

Overtorment: this PR helped! I applied this patch to 12rc6 and the delay between when wallet is unlocked and when can start open channel psbt funding workflow is now 2-3 sec.

of course, disabling graph sync would be ideal, but we have https://github.com/lightningnetwork/lnd/issues/3324 for that 


here's a info-level log for reference:


```
2021-01-20 14:03:46.158 12411-12452/com.example.rnlnd V/ReactNativeLND: starting LND in /storage/emulated/0/Android/data/com.example.rnlnd/files/.lnd
2021-01-20 14:03:46.263 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.263 [INF] LTND: REST API is disabled!
2021-01-20 14:03:46.263 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.263 [INF] LTND: Listening on the p2p interface is disabled!
2021-01-20 14:03:46.263 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.263 [WRN] LTND: open /storage/emulated/0/Android/data/com.example.rnlnd/files/.lnd/lnd.conf: no such file or directory
2021-01-20 14:03:46.264 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.264 [INF] LTND: Version: 0.12.0-beta.rc6 commit=v0.12.0-beta.rc6-dirty, build=development, logging=default, debuglevel=info
2021-01-20 14:03:46.264 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.264 [INF] LTND: Active chain: Bitcoin (network=mainnet)
2021-01-20 14:03:46.264 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.264 [INF] LTND: Opening the main database, this might take a few minutes...
2021-01-20 14:03:46.264 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.264 [INF] LTND: Opening bbolt database, sync_freelist=true, auto_compact=false
2021-01-20 14:03:46.297 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.296 [INF] CHDB: Checking for schema update: latest_version=20, db_version=20
2021-01-20 14:03:46.297 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.296 [INF] LTND: Database now open (time_to_open=32.3617ms)!
2021-01-20 14:03:46.392 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.391 [INF] BTCN: Loaded 1656 addresses from file '/storage/emulated/0/Android/data/com.example.rnlnd/files/.lnd/data/chain/bitcoin/mainnet/peers.json'
2021-01-20 14:03:46.392 12411-12483/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.391 [INF] BTCN: Registering block subscription: id=1
2021-01-20 14:03:46.397 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.392 [INF] BTCN: Broadcaster now active
2021-01-20 14:03:46.397 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.392 [INF] RPCS: Password RPC server listening on bufconn
2021-01-20 14:03:46.397 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.392 [INF] LTND: Waiting for wallet encryption password. Use `lncli create` to create a wallet, `lncli unlock` to unlock an existing wallet, or `lncli changepassword` to change the password of an existing wallet and unlock it.
2021-01-20 14:03:46.409 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.404 [INF] BTCN: 20 addresses found from DNS seed x49.seed.bitcoin.sipa.be
2021-01-20 14:03:46.410 12411-12502/com.example.rnlnd V/ReactNativeLND: lnd started ===========================================================================
2021-01-20 14:03:46.414 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.414 [INF] BTCN: 36 addresses found from DNS seed dnsseed.bitcoin.dashjr.org
2021-01-20 14:03:46.421 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.420 [INF] BTCN: 29 addresses found from DNS seed x49.seed.bitcoin.jonasschnelli.ch
2021-01-20 14:03:46.433 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.433 [INF] BTCN: 12 addresses found from DNS seed x49.dnsseed.bluematt.me
2021-01-20 14:03:46.438 12411-12451/com.example.rnlnd W/ReactNativeJS: true
2021-01-20 14:03:46.471 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.469 [INF] BTCN: 37 addresses found from DNS seed x49.seed.bitcoinstats.com
2021-01-20 14:03:46.501 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.500 [INF] BTCN: Waiting for more block headers, then will start cfheaders sync from height 666907...
2021-01-20 14:03:46.502 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.500 [INF] BTCN: Starting cfheaders sync from (block_height=666907, block_hash=0000000000000000000191021f85b8ab29908db9fb9a544e39fbc9a0659d748c) to (block_height=666907, block_hash=0000000000000000000191021f85b8ab29908db9fb9a544e39fbc9a0659d748c)
2021-01-20 14:03:46.502 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.500 [INF] BTCN: Starting cfheaders sync for filter_type=0
2021-01-20 14:03:46.502 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.500 [INF] BTCN: New valid peer 79.98.105.138:8333 (outbound) (/Satoshi:0.21.0/)
2021-01-20 14:03:46.502 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.501 [INF] BTCN: Syncing to block height 666907 from peer 79.98.105.138:8333
2021-01-20 14:03:46.502 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.501 [INF] BTCN: Fetching set of headers from tip (height=666907) from peer 79.98.105.138:8333
2021-01-20 14:03:46.527 12411-12451/com.example.rnlnd D/SoLoader: About to load: libreactnativeblob.so
2021-01-20 14:03:46.527 12411-12451/com.example.rnlnd D/SoLoader: libreactnativeblob.so not found on /data/data/com.example.rnlnd/lib-main
2021-01-20 14:03:46.528 12411-12451/com.example.rnlnd D/SoLoader: libreactnativeblob.so found on /data/app/com.example.rnlnd-S2T5f-RkrQlFWYhyxnmn0g==/lib/x86
2021-01-20 14:03:46.528 12411-12451/com.example.rnlnd D/SoLoader: Not resolving dependencies for libreactnativeblob.so
2021-01-20 14:03:46.531 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.531 [INF] BTCN: 40 addresses found from DNS seed seed.bitnodes.io
2021-01-20 14:03:46.546 12411-12451/com.example.rnlnd D/SoLoader: Loaded: libreactnativeblob.so
2021-01-20 14:03:46.593 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.592 [INF] BTCN: Fetching set of checkpointed cfheaders filters from height=666907, hash=01d9f2a49a8f4d66e123efa77f4fa3ad43399c6901f76ee33cda40b79be9b8fd
2021-01-20 14:03:46.593 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.593 [INF] BTCN: Starting to query for cfheaders from checkpoint_interval=666, checkpoints=666
2021-01-20 14:03:46.593 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.593 [INF] BTCN: Fully caught up with cfheaders at height 666907, waiting at tip for new blocks
2021-01-20 14:03:46.642 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.641 [WRN] BTCN: Banning peer 140.190.21.8:8333: duration=48h0m0s, reason=peer was unable to serve compact filters
2021-01-20 14:03:46.647 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.647 [INF] BTCN: Lost peer 140.190.21.8:8333 (outbound)
2021-01-20 14:03:46.668 12411-12508/com.example.rnlnd D/SoLoader: About to load: libimagepipeline.so
2021-01-20 14:03:46.668 12411-12508/com.example.rnlnd D/SoLoader: libimagepipeline.so not found on /data/data/com.example.rnlnd/lib-main
2021-01-20 14:03:46.668 12411-12508/com.example.rnlnd D/SoLoader: libimagepipeline.so found on /data/app/com.example.rnlnd-S2T5f-RkrQlFWYhyxnmn0g==/lib/x86
2021-01-20 14:03:46.668 12411-12508/com.example.rnlnd D/SoLoader: Not resolving dependencies for libimagepipeline.so
2021-01-20 14:03:46.674 12411-12508/com.example.rnlnd D/SoLoader: Loaded: libimagepipeline.so
2021-01-20 14:03:46.678 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.676 [WRN] BTCN: Banning peer 212.115.108.181:8333: duration=48h0m0s, reason=peer was unable to serve compact filters
2021-01-20 14:03:46.680 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.680 [INF] BTCN: Lost peer 212.115.108.181:8333 (outbound)
2021-01-20 14:03:46.703 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.703 [INF] BTCN: New valid peer 13.91.246.35:8333 (outbound) (/btcwire:0.5.0/btcd:0.12.0/)
2021-01-20 14:03:46.710 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.710 [INF] BTCN: New valid peer 13.91.246.35:8333 (outbound) (/btcwire:0.5.0/btcd:0.12.0/)
2021-01-20 14:03:46.826 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.826 [WRN] BTCN: Banning peer 8.210.229.68:8333: duration=48h0m0s, reason=peer was unable to serve compact filters
2021-01-20 14:03:46.829 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:46.829 [INF] BTCN: Lost peer 8.210.229.68:8333 (outbound)
2021-01-20 14:03:47.116 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:47.116 [INF] BTCN: New valid peer 94.154.159.99:8333 (outbound) (/Satoshi:0.20.1/Knots:20200815/)
2021-01-20 14:03:47.914 12411-12452/com.example.rnlnd V/ReactNativeLND: unlocking wallet with password -->gsomgsomgsom<--
2021-01-20 14:03:47.952 12411-12452/com.example.rnlnd W/m.example.rnln: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
2021-01-20 14:03:48.332 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:48.332 [INF] BTCN: New valid peer 178.48.165.143:8333 (outbound) (/btcwire:0.5.0/btcd:0.20.1/)
2021-01-20 14:03:49.528 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:49.528 [INF] LNWL: Opened wallet
2021-01-20 14:03:49.731 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:49.731 [INF] CHRE: Primary chain is set to: bitcoin
2021-01-20 14:03:49.731 12411-12484/com.example.rnlnd V/ReactNativeLND: lnd unlocked ===========================================================================
2021-01-20 14:03:49.734 12411-12451/com.example.rnlnd W/ReactNativeJS: true
2021-01-20 14:03:49.752 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:49.752 [INF] CHRE: Using external fee estimator https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json: cached=true
2021-01-20 14:03:49.753 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:49.752 [INF] LNWL: Starting web API fee estimator
2021-01-20 14:03:51.299 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.298 [INF] LNWL: The wallet has been unlocked without a time limit
2021-01-20 14:03:51.299 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.299 [INF] CHRE: LightningWallet opened
2021-01-20 14:03:51.309 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.309 [INF] HSWC: Restoring in-memory circuit state from disk
2021-01-20 14:03:51.316 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.316 [INF] HSWC: Payment circuits loaded: num_pending=0, num_open=0
2021-01-20 14:03:51.360 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.360 [INF] LTND: Channel backup proxy channel notifier starting
2021-01-20 14:03:51.360 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.360 [INF] ATPL: Instantiating autopilot with active=false, max_channels=5, allocation=0.600000, min_chan_size=20000, max_chan_size=16777215, private=false, min_confs=1, conf_target=3
2021-01-20 14:03:51.360 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.360 [INF] RPCS: RPC server listening on bufconn
2021-01-20 14:03:51.361 12411-12502/com.example.rnlnd V/ReactNativeLND: lnd is ready ===========================================================================
2021-01-20 14:03:51.363 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.362 [INF] LTND: Waiting for chain backend to finish sync, start_height=666907
2021-01-20 14:03:51.531 12411-12452/com.example.rnlnd V/ReactNativeLND: openChannelPsbt
2021-01-20 14:03:51.601 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:51.601 [ERR] RPCS: [/lnrpc.Lightning/OpenChannel]: server is still in the process of starting
2021-01-20 14:03:52.302 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.302 [INF] BTCN: Registering block subscription: id=2
2021-01-20 14:03:52.342 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.342 [INF] LNWL: Started rescan from block 0000000000000000000191021f85b8ab29908db9fb9a544e39fbc9a0659d748c (height 666907) for 0 addresses
2021-01-20 14:03:52.342 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.342 [INF] BTCN: Canceling block subscription: id=2
2021-01-20 14:03:52.342 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.342 [INF] LNWL: Catching up block hashes to height 666907, this might take a while
2021-01-20 14:03:52.342 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.342 [INF] BTCN: Registering block subscription: id=3
2021-01-20 14:03:52.344 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.344 [INF] LNWL: Done catching up block hashes
2021-01-20 14:03:52.344 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.344 [INF] LNWL: Finished rescan for 0 addresses (synced to block 0000000000000000000191021f85b8ab29908db9fb9a544e39fbc9a0659d748c, height 666907)
2021-01-20 14:03:52.363 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.362 [INF] LTND: Chain backend is fully synced (end_height=666907)!
2021-01-20 14:03:52.363 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.363 [WRN] HLCK: check: disk space configured with 0 attempts, skipping it
2021-01-20 14:03:52.363 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.363 [WRN] HLCK: check: tls configured with 0 attempts, skipping it
2021-01-20 14:03:52.363 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.363 [INF] PRNF: PeerNotifier starting
2021-01-20 14:03:52.364 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.364 [INF] BTCN: Registering block subscription: id=4
2021-01-20 14:03:52.364 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.364 [INF] HSWC: Starting HTLC Switch
2021-01-20 14:03:52.364 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.364 [INF] NTFN: New block epoch subscription
2021-01-20 14:03:52.364 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.364 [INF] NTFN: New block epoch subscription
2021-01-20 14:03:52.365 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.365 [INF] NTFN: New block epoch subscription
2021-01-20 14:03:52.365 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.365 [INF] NTFN: New block epoch subscription
2021-01-20 14:03:52.366 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.366 [INF] NTFN: New block epoch subscription
2021-01-20 14:03:52.367 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.367 [INF] DISC: Authenticated Gossiper is starting
2021-01-20 14:03:52.367 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.367 [INF] BRAR: Starting contract observer, watching for breaches.
2021-01-20 14:03:52.367 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.367 [INF] NTFN: New block epoch subscription
2021-01-20 14:03:52.382 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.382 [INF] CHFT: Adding 0 channels to event store
2021-01-20 14:03:52.382 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.382 [INF] CHBU: Starting chanbackup.SubSwapper
2021-01-20 14:03:52.389 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.389 [INF] CHBU: Updating backup file at /storage/emulated/0/Android/data/com.example.rnlnd/files/.lnd/data/chain/bitcoin/mainnet/channel.backup
2021-01-20 14:03:52.391 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.391 [INF] CHBU: Swapping old multi backup file from /storage/emulated/0/Android/data/com.example.rnlnd/files/.lnd/data/chain/bitcoin/mainnet/temp-dont-use.backup to /storage/emulated/0/Android/data/com.example.rnlnd/files/.lnd/data/chain/bitcoin/mainnet/channel.backup
2021-01-20 14:03:52.398 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.398 [INF] SRVR: Initializing peer network bootstrappers!
2021-01-20 14:03:52.398 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.398 [INF] SRVR: Creating DNS peer bootstrapper with seeds: [[nodes.lightning.directory soa.nodes.lightning.directory] [lseed.bitcoinstats.com ]]
2021-01-20 14:03:52.398 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.398 [INF] DISC: Attempting to bootstrap with: Authenticated Channel Graph
2021-01-20 14:03:52.403 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.403 [INF] DISC: Obtained 4 addrs to bootstrap network with
2021-01-20 14:03:52.429 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.429 [ERR] SRVR: Unable to connect to 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605@ki5uack5xb4gicfnpfavzdibojfu3qvwtlg3ca7eyjxik7tgwfxummqd.onion:9735: dial tcp: lookup ki5uack5xb4gicfnpfavzdibojfu3qvwtlg3ca7eyjxik7tgwfxummqd.onion: No address associated with hostname
2021-01-20 14:03:52.429 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.429 [ERR] SRVR: Unable to connect to 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605@m4td4iciuvmnhpwe7qsl5jpjzjoewjvtriecqyax2ztjljeofj6lfmid.onion:9735: dial tcp: lookup m4td4iciuvmnhpwe7qsl5jpjzjoewjvtriecqyax2ztjljeofj6lfmid.onion: No address associated with hostname
2021-01-20 14:03:52.429 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.429 [ERR] SRVR: Unable to connect to 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605@ki5uack5xb4gicfnpfavzdibojfu3qvwtlg3ca7eyjxik7tgwfxummqd.onion:9735: dial tcp: lookup ki5uack5xb4gicfnpfavzdibojfu3qvwtlg3ca7eyjxik7tgwfxummqd.onion: No address associated with hostname
2021-01-20 14:03:52.429 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.429 [ERR] SRVR: Unable to connect to 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605@m4td4iciuvmnhpwe7qsl5jpjzjoewjvtriecqyax2ztjljeofj6lfmid.onion:9735: dial tcp: lookup m4td4iciuvmnhpwe7qsl5jpjzjoewjvtriecqyax2ztjljeofj6lfmid.onion: No address associated with hostname
2021-01-20 14:03:52.562 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.561 [INF] SRVR: Established connection to: 03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f@34.239.230.56:9735
2021-01-20 14:03:52.562 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.562 [INF] SRVR: Finalizing connection to 03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f@34.239.230.56:9735, inbound=false
2021-01-20 14:03:52.562 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.562 [INF] SRVR: Pruned peer 03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f from persistent connections, peer has no open channels
2021-01-20 14:03:52.641 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.641 [INF] PEER: Negotiated chan series queries with 03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f
2021-01-20 14:03:52.641 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.641 [INF] DISC: Creating new GossipSyncer for peer=03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f
2021-01-20 14:03:52.641 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.641 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): requesting new chans from height=0 and 666907 blocks after
2021-01-20 14:03:52.750 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.750 [INF] SRVR: Established connection to: 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605@128.199.202.168:9735
2021-01-20 14:03:52.750 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.750 [INF] SRVR: Finalizing connection to 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605@128.199.202.168:9735, inbound=false
2021-01-20 14:03:52.754 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.753 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.756 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.756 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1551
2021-01-20 14:03:52.831 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.831 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.835 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.835 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.836 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.836 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.838 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.838 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.905 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.905 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.906 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.906 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1501
2021-01-20 14:03:52.907 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.907 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.908 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.908 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1501
2021-01-20 14:03:52.909 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.909 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.910 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.910 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.911 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.911 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.912 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.912 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1501
2021-01-20 14:03:52.913 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.913 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.913 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.913 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.925 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.925 [INF] PEER: Negotiated chan series queries with 024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605
2021-01-20 14:03:52.925 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.925 [INF] DISC: Creating new GossipSyncer for peer=024b9a1fa8e006f1e3937f65f66c408e6da8e1ca728ea43222a7381df1cc449605
2021-01-20 14:03:52.981 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.981 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.982 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.982 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1528
2021-01-20 14:03:52.984 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.984 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1503
2021-01-20 14:03:52.986 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.986 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1500
2021-01-20 14:03:52.987 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.987 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): buffering chan range reply of size=1497
2021-01-20 14:03:52.987 12411-12484/com.example.rnlnd I/GoLog: 2021-01-20 14:03:52.987 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): filtering through 31582 chans
2021-01-20 14:03:53.294 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.294 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): remote peer has no new chans
2021-01-20 14:03:53.294 12411-12488/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.294 [INF] DISC: GossipSyncer(03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f): applying gossipFilter(start=2021-01-20 14:03:53.29450575 +0000 UTC m=+7.105277941, end=2157-02-26 20:32:08.29450575 +0000 UTC m=+4294967302.105277941)
2021-01-20 14:03:53.465 12411-12452/com.example.rnlnd V/ReactNativeLND: openChannelPsbt
2021-01-20 14:03:53.481 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.478 [INF] FNDG: Initiating fundingRequest(local_amt=0.001 BTC (subtract_fees=false), push_amt=0 mSAT, chain_hash=000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f, peer=03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f, dust_limit=0.00000573 BTC, min_confs=1)
2021-01-20 14:03:53.505 12411-12492/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.504 [INF] FNDG: Target commit tx sat/kw for pendingID(a2d9a1c69cdae6fb7c1eb93db7d7528b2f46d81b9aaef0a382f055914c33b711): 20811
2021-01-20 14:03:53.505 12411-12481/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.505 [INF] FNDG: Starting funding workflow with 34.239.230.56:9735 for pending_id(a2d9a1c69cdae6fb7c1eb93db7d7528b2f46d81b9aaef0a382f055914c33b711), committype=tweakless
2021-01-20 14:03:53.607 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.604 [INF] FNDG: Recv'd fundingResponse for pending_id(a2d9a1c69cdae6fb7c1eb93db7d7528b2f46d81b9aaef0a382f055914c33b711)
2021-01-20 14:03:53.607 12411-12502/com.example.rnlnd I/GoLog: 2021-01-20 14:03:53.604 [INF] FNDG: pendingChan(a2d9a1c69cdae6fb7c1eb93db7d7528b2f46d81b9aaef0a382f055914c33b711): remote party proposes num_confs=3, csv_delay=720
2021-01-20 14:03:53.888 12411-12451/com.example.rnlnd W/ReactNativeJS: { pendingChanId: 'otmhxpza5vt8Hrk9t9dSiy9G2BuarvCjgvBVkUwztxE=',
      psbtFund: 
       { fundingAddress: 'bc1qse2dd67x2ct2h9adsk8vhr2durr70fc35v6zt5v88xfaxsvz0uzs4rkafv',
         fundingAmount: '100000',
         psbt: 'cHNidP8BADUCAAAAAAGghgEAAAAAACIAIIZU1uvGVharl62FjsuNTeDH56cRozQl0Yc5k9NBgn8FAAAAAAAA' } }

```
halseth: > Unit tests look more unhappy than usual - `TestPruneChannelGraphDoubleDisabled` failure seems related?

Fixed by making the delay settable in the config.

Patch:
diff --git a/routing/router.go b/routing/router.go
index 0cb0ced8e..f5ee52f1e 100644
--- a/routing/router.go
+++ b/routing/router.go
@@ -43,6 +43,12 @@ const (
 	// if a channel should be pruned or not.
 	DefaultChannelPruneExpiry = time.Duration(time.Hour * 24 * 14)
 
+	// DefaultFirstTimePruneDelay is the time we'll wait after startup
+	// before attempting to prune the graph for zombie channels. We don't
+	// do it immediately after startup to allow lnd to start up without
+	// getting blocked by this job.
+	DefaultFirstTimePruneDelay = 30 * time.Second
+
 	// defaultStatInterval governs how often the router will log non-empty
 	// stats related to processing new channels, updates, or node
 	// announcements.
@@ -306,6 +312,12 @@ type Config struct {
 	// should examine the channel graph to garbage collect zombie channels.
 	GraphPruneInterval time.Duration
 
+	// FirstTimePruneDelay is the time we'll wait after startup before
+	// attempting to prune the graph for zombie channels. We don't do it
+	// immediately after startup to allow lnd to start up without getting
+	// blocked by this job.
+	FirstTimePruneDelay time.Duration
+
 	// QueryBandwidth is a method that allows the router to query the lower
 	// link layer to determine the up to date available bandwidth at a
 	// prospective link to be traversed. If the  link isn't available, then
@@ -485,11 +497,21 @@ func (r *ChannelRouter) Start() error {
 
 	// If AssumeChannelValid is present, then we won't rely on pruning
 	// channels from the graph based on their spentness, but whether they
-	// are considered zombies or not.
+	// are considered zombies or not. We will start zombie pruning after a
+	// small delay, to avoid slowing down startup of lnd.
 	if r.cfg.AssumeChannelValid {
-		if err := r.pruneZombieChans(); err != nil {
-			return err
-		}
+		time.AfterFunc(r.cfg.FirstTimePruneDelay, func() {
+			select {
+			case <-r.quit:
+				return
+			default:
+			}
+
+			log.Info("Initial zombie prune starting")
+			if err := r.pruneZombieChans(); err != nil {
+				log.Errorf("Unable to prune zombies: %v", err)
+			}
+		})
 	} else {
 		// Otherwise, we'll use our filtered chain view to prune
 		// channels as soon as they are detected as spent on-chain.
@@ -875,6 +897,9 @@ func (r *ChannelRouter) pruneZombieChans() error {
 	}
 
 	log.Infof("Pruning %v zombie channels", len(chansToPrune))
+	if len(chansToPrune) == 0 {
+		return nil
+	}
 
 	// With the set of zombie-like channels obtained, we'll do another pass
 	// to delete them from the channel graph.
diff --git a/server.go b/server.go
index 7c6681b6d..a3240dee9 100644
--- a/server.go
+++ b/server.go
@@ -769,20 +769,21 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
 	s.controlTower = routing.NewControlTower(paymentControl)
 
 	s.chanRouter, err = routing.New(routing.Config{
-		Graph:              chanGraph,
-		Chain:              cc.ChainIO,
-		ChainView:          cc.ChainView,
-		Payer:              s.htlcSwitch,
-		Control:            s.controlTower,
-		MissionControl:     s.missionControl,
-		SessionSource:      paymentSessionSource,
-		ChannelPruneExpiry: routing.DefaultChannelPruneExpiry,
-		GraphPruneInterval: time.Duration(time.Hour),
-		QueryBandwidth:     queryBandwidth,
-		AssumeChannelValid: cfg.Routing.AssumeChannelValid,
-		NextPaymentID:      sequencer.NextID,
-		PathFindingConfig:  pathFindingConfig,
-		Clock:              clock.NewDefaultClock(),
+		Graph:               chanGraph,
+		Chain:               cc.ChainIO,
+		ChainView:           cc.ChainView,
+		Payer:               s.htlcSwitch,
+		Control:             s.controlTower,
+		MissionControl:      s.missionControl,
+		SessionSource:       paymentSessionSource,
+		ChannelPruneExpiry:  routing.DefaultChannelPruneExpiry,
+		GraphPruneInterval:  time.Hour,
+		FirstTimePruneDelay: routing.DefaultFirstTimePruneDelay,
+		QueryBandwidth:      queryBandwidth,
+		AssumeChannelValid:  cfg.Routing.AssumeChannelValid,
+		NextPaymentID:       sequencer.NextID,
+		PathFindingConfig:   pathFindingConfig,
+		Clock:               clock.NewDefaultClock(),
 	})
 	if err != nil {
 		return nil, fmt.Errorf("can't create router: %v", err)


Test patch:
diff --git a/routing/router_test.go b/routing/router_test.go
index 19ad1ef32..a7c082e99 100644
--- a/routing/router_test.go
+++ b/routing/router_test.go
@@ -1541,6 +1541,9 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
 		Control:            makeMockControlTower(),
 		ChannelPruneExpiry: time.Hour * 24,
 		GraphPruneInterval: time.Hour * 2,
+
+		// We'll set the delay to zero to prune immediately.
+		FirstTimePruneDelay: 0,
 	})
 	if err != nil {
 		t.Fatalf("unable to create router %v", err)
@@ -2157,6 +2160,9 @@ func testPruneChannelGraphDoubleDisabled(t *testing.T, assumeValid bool) {
 	if !assumeValid {
 		assertChannelsPruned(t, ctx.graph, testChannels)
 	} else {
+		// Sleep to allow the pruning to finish.
+		time.Sleep(200 * time.Millisecond)
+
 		prunedChannel := testChannels[len(testChannels)-1].ChannelID
 		assertChannelsPruned(t, ctx.graph, testChannels, prunedChannel)
 	}