Skip to content

Commit

Permalink
Add metric for commit lock wait time
Browse files Browse the repository at this point in the history
  • Loading branch information
ctring committed Oct 31, 2023
1 parent 014d3e3 commit 8914088
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pageserver/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ pub static LIVE_CONNECTIONS_COUNT: Lazy<IntGaugeVec> = Lazy::new(|| {
.expect("failed to define a metric")
});

// Remotexact

pub static LAST_RECEIVED_LSN: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"pageserver_last_received_lsn",
Expand All @@ -652,6 +654,15 @@ pub static LSN_RECEIVE_DELAY: Lazy<HistogramVec> = Lazy::new(|| {
.expect("failed to define a metric")
});

pub static WAL_COMMIT_WRITER_LOCK_WAIT_TIME: Lazy<Histogram> = Lazy::new(|| {
register_histogram!(
"pageserver_wal_commit_writer_lock_wait_seconds",
"Time spent waiting for the commit writer lock",
CRITICAL_OP_BUCKETS.into(),
)
.expect("failed to define a metric")
});

// remote storage metrics

/// NB: increment _after_ recording the current value into [`REMOTE_TIMELINE_CLIENT_CALLS_STARTED_HIST`].
Expand Down
4 changes: 4 additions & 0 deletions pageserver/src/pgdatadir_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use super::tenant::{PageReconstructError, Timeline};
use crate::context::RequestContext;
use crate::keyspace::{KeySpace, KeySpaceAccum};
use crate::metrics::WAL_COMMIT_WRITER_LOCK_WAIT_TIME;
use crate::repository::*;
use crate::walrecord::NeonWalRecord;
use anyhow::Context;
Expand Down Expand Up @@ -1180,7 +1181,10 @@ impl<'a> DatadirModification<'a> {
/// All the modifications in this atomic update are stamped by the specified LSN.
///
pub async fn commit(&mut self) -> anyhow::Result<()> {
let timer = WAL_COMMIT_WRITER_LOCK_WAIT_TIME.start_timer();
let writer = self.tline.writer().await;
timer.stop_and_record();

let lsn = self.lsn;
let pending_nblocks = self.pending_nblocks;
self.pending_nblocks = 0;
Expand Down

0 comments on commit 8914088

Please sign in to comment.