Skip to content

Commit 8d2bfc4

Browse files
committed
Log before+after ChannelMonitor/Manager updates for visibility
I realized on my own node that I don't have any visibility into how long a monitor or manager persistence call takes, potentially blocking other operations. This makes it much more clear by adding a relevant log_trace!() print immediately before and immediately after persistence.
1 parent 7aa2cac commit 8d2bfc4

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ impl BackgroundProcessor {
214214
let updates_available =
215215
channel_manager.await_persistable_update_timeout(Duration::from_millis(100));
216216
if updates_available {
217+
log_trace!(logger, "Persisting ChannelManager...");
217218
persister.persist_manager(&*channel_manager)?;
219+
log_trace!(logger, "Done persisting ChannelManager.");
218220
}
219221
// Exit the loop if the background processor was requested to stop.
220222
if stop_thread.load(Ordering::Acquire) == true {

lightning/src/chain/chainmonitor.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,17 +276,15 @@ where C::Target: chain::Filter,
276276
return Err(ChannelMonitorUpdateErr::PermanentFailure)},
277277
hash_map::Entry::Vacant(e) => e,
278278
};
279+
let funding_txo = monitor.get_funding_txo();
280+
log_trace!(self.logger, "Got new Channel Monitor for channel {}", log_bytes!(funding_txo.0.to_channel_id()[..]));
279281
if let Err(e) = self.persister.persist_new_channel(funding_outpoint, &monitor) {
280282
log_error!(self.logger, "Failed to persist new channel data");
281283
return Err(e);
282284
}
283-
{
284-
let funding_txo = monitor.get_funding_txo();
285-
log_trace!(self.logger, "Got new Channel Monitor for channel {}", log_bytes!(funding_txo.0.to_channel_id()[..]));
286-
287-
if let Some(ref chain_source) = self.chain_source {
288-
monitor.load_outputs_to_watch(chain_source);
289-
}
285+
log_trace!(self.logger, "Finished persisting new Channel Monitor for channel {}", log_bytes!(funding_txo.0.to_channel_id()[..]));
286+
if let Some(ref chain_source) = self.chain_source {
287+
monitor.load_outputs_to_watch(chain_source);
290288
}
291289
entry.insert(monitor);
292290
Ok(())
@@ -321,6 +319,7 @@ where C::Target: chain::Filter,
321319
if let Err(ref e) = persist_res {
322320
log_error!(self.logger, "Failed to persist channel monitor update: {:?}", e);
323321
}
322+
log_trace!(self.logger, "Finished persisting Channel Monitor Update for channel {}", log_funding_info!(monitor));
324323
if update_res.is_err() {
325324
Err(ChannelMonitorUpdateErr::PermanentFailure)
326325
} else {

0 commit comments

Comments
 (0)