Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions crates/core/src/db/datastore/locking_tx_datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2115,39 +2115,45 @@ impl traits::MutTx for Locking {
}

fn rollback_mut_tx(&self, ctx: &ExecutionContext, mut tx: Self::MutTxId) {
let txn_type = &ctx.txn_type();
let db = &ctx.database();
let reducer = ctx.reducer_name().unwrap_or_default();
let elapsed_time = tx.timer.elapsed();
let cpu_time = elapsed_time - tx.lock_wait_time;
DB_METRICS
.rdb_num_txns_rolledback
.with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or(""))
.rdb_num_txns
.with_label_values(txn_type, db, reducer, &false)
.inc();
DB_METRICS
.rdb_txn_cpu_time_sec
.with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or(""))
.with_label_values(txn_type, db, reducer)
.observe(cpu_time.as_secs_f64());
DB_METRICS
.rdb_txn_elapsed_time_sec
.with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or(""))
.with_label_values(txn_type, db, reducer)
.observe(elapsed_time.as_secs_f64());
tx.lock.rollback();
}

fn commit_mut_tx(&self, ctx: &ExecutionContext, mut tx: Self::MutTxId) -> super::Result<Option<TxData>> {
let txn_type = &ctx.txn_type();
let db = &ctx.database();
let reducer = ctx.reducer_name().unwrap_or_default();
let elapsed_time = tx.timer.elapsed();
let cpu_time = elapsed_time - tx.lock_wait_time;
// Note, we record empty transactions in our metrics.
// That is, transactions that don't write any rows to the commit log.
DB_METRICS
.rdb_num_txns_committed
.with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or(""))
.rdb_num_txns
.with_label_values(txn_type, db, reducer, &true)
.inc();
DB_METRICS
.rdb_txn_cpu_time_sec
.with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or(""))
.with_label_values(txn_type, db, reducer)
.observe(cpu_time.as_secs_f64());
DB_METRICS
.rdb_txn_elapsed_time_sec
.with_label_values(&ctx.txn_type(), &ctx.database(), ctx.reducer_name().unwrap_or(""))
.with_label_values(txn_type, db, reducer)
.observe(elapsed_time.as_secs_f64());
tx.lock.commit()
}
Expand Down
13 changes: 4 additions & 9 deletions crates/core/src/db/db_metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,10 @@ metrics_group!(
#[labels(txn_type: TransactionType, db: Address, reducer: str, table_id: u32)]
pub rdb_num_index_seeks: IntCounterVec,

#[name = spacetime_num_txns_committed_cumulative]
#[help = "The cumulative number of committed transactions"]
#[labels(txn_type: TransactionType, db: Address, reducer: str)]
pub rdb_num_txns_committed: IntCounterVec,

#[name = spacetime_num_txns_rolledback_cumulative]
#[help = "The cumulative number of rolled back transactions"]
#[labels(txn_type: TransactionType, db: Address, reducer: str)]
pub rdb_num_txns_rolledback: IntCounterVec,
#[name = spacetime_num_txns_cumulative]
#[help = "The cumulative number of transactions, including both commits and rollbacks"]
#[labels(txn_type: TransactionType, db: Address, reducer: str, committed: bool)]
pub rdb_num_txns: IntCounterVec,

#[name = spacetime_txn_elapsed_time_sec]
#[help = "The total elapsed (wall) time of a transaction (in seconds)"]
Expand Down
1 change: 1 addition & 0 deletions crates/core/src/util/typed_prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl_prometheusvalue_string!(
Address,
TransactionType,
AbiCall,
bool,
u8,
u16,
u32,
Expand Down