From 02adff3b63721b9f6134e4a13f36c536d022dc01 Mon Sep 17 00:00:00 2001 From: hvlad Date: Sat, 12 May 2012 09:48:32 +0000 Subject: [PATCH] Improvement CORE-3598 : TRACE: add statistics of actions that were after transaction finished --- src/jrd/jrd.cpp | 9 ++++++--- src/jrd/tra.cpp | 11 ++++++----- src/jrd/tra_proto.h | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index dbeb1c3bc5..1d54cd1625 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -6232,8 +6232,9 @@ void JTransaction::freeEngineData(Firebird::IStatus* user_status) tdbb->getDatabase()->dbb_ast_flags & DBB_shutdown || tdbb->getAttachment()->att_flags & ATT_shutdown) { + TraceTransactionEnd trace(transaction, false, false); EDS::Transaction::jrdTransactionEnd(tdbb, transaction, false, false, false); - TRA_release_transaction(tdbb, transaction); + TRA_release_transaction(tdbb, transaction, &trace); } else TRA_rollback(tdbb, transaction, false, false); @@ -6286,8 +6287,9 @@ static unsigned int purge_transactions(thread_db* tdbb, if ((transaction->tra_flags & TRA_prepared) || (dbb->dbb_ast_flags & DBB_shutdown) || (att_flags & ATT_shutdown)) { + TraceTransactionEnd trace(transaction, false, false); // need ability to indicate prepared (in limbo) transaction EDS::Transaction::jrdTransactionEnd(tdbb, transaction, false, false, true); - TRA_release_transaction(tdbb, transaction); + TRA_release_transaction(tdbb, transaction, &trace); } else if (force_flag) TRA_rollback(tdbb, transaction, false, true); @@ -6307,7 +6309,8 @@ static unsigned int purge_transactions(thread_db* tdbb, attachment->att_dbkey_trans = NULL; if ((dbb->dbb_ast_flags & DBB_shutdown) || (att_flags & ATT_shutdown)) { - TRA_release_transaction(tdbb, trans_dbk); + TraceTransactionEnd trace(trans_dbk, false, false); + TRA_release_transaction(tdbb, trans_dbk, &trace); } else { diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp index 7fa1cb2ed7..00f0a47259 100644 --- a/src/jrd/tra.cpp +++ b/src/jrd/tra.cpp @@ -410,8 +410,7 @@ void TRA_commit(thread_db* tdbb, jrd_tra* transaction, const bool retaining_flag LCK_convert(tdbb, lock, LCK_write, LCK_WAIT); --transaction->tra_use_count; - trace.finish(res_successful); - TRA_release_transaction(tdbb, transaction); + TRA_release_transaction(tdbb, transaction, &trace); } @@ -1012,7 +1011,7 @@ jrd_tra* TRA_reconnect(thread_db* tdbb, const UCHAR* id, USHORT length) } -void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction) +void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction, Jrd::TraceTransactionEnd* trace) { /************************************** * @@ -1130,6 +1129,9 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction) if (transaction->tra_flags & TRA_precommitted) TRA_precommited(tdbb, transaction->tra_number, 0); + if (trace) + trace->finish(res_successful); + // Unlink the transaction from the database block for (jrd_tra** ptr = &attachment->att_transactions; *ptr; ptr = &(*ptr)->tra_next) @@ -1314,8 +1316,7 @@ void TRA_rollback(thread_db* tdbb, jrd_tra* transaction, const bool retaining_fl TRA_set_state(tdbb, transaction, transaction->tra_number, state); - trace.finish(res_successful); - TRA_release_transaction(tdbb, transaction); + TRA_release_transaction(tdbb, transaction, &trace); } diff --git a/src/jrd/tra_proto.h b/src/jrd/tra_proto.h index 4190fc4329..8ac6682e04 100644 --- a/src/jrd/tra_proto.h +++ b/src/jrd/tra_proto.h @@ -29,6 +29,7 @@ namespace Jrd { class Attachment; class Database; + class TraceTransactionEnd; } bool TRA_active_transactions(Jrd::thread_db*, Jrd::Database*); @@ -50,7 +51,7 @@ void TRA_post_resources(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::ResourceList&); bool TRA_precommited(Jrd::thread_db*, SLONG, SLONG); void TRA_prepare(Jrd::thread_db*, Jrd::jrd_tra*, USHORT, const UCHAR*); Jrd::jrd_tra* TRA_reconnect(Jrd::thread_db*, const UCHAR*, USHORT); -void TRA_release_transaction(Jrd::thread_db*, Jrd::jrd_tra*); +void TRA_release_transaction(Jrd::thread_db*, Jrd::jrd_tra*, Jrd::TraceTransactionEnd*); void TRA_rollback(Jrd::thread_db*, Jrd::jrd_tra*, const bool, const bool); void TRA_set_state(Jrd::thread_db*, Jrd::jrd_tra*, SLONG, SSHORT); int TRA_snapshot_state(Jrd::thread_db*, const Jrd::jrd_tra*, SLONG);