summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/TransactionI.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-06-12 14:38:34 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-06-12 14:38:34 +0000
commitd1a1ef0f00e201f6bb5a90da34f480c1f1cd284a (patch)
treee7fc0d944bfa2c1800921f56861db2a4bb37d936 /cpp/src/Freeze/TransactionI.cpp
parentFixed bug where allocation could return before the Glacier2 filters were (diff)
downloadice-d1a1ef0f00e201f6bb5a90da34f480c1f1cd284a.tar.bz2
ice-d1a1ef0f00e201f6bb5a90da34f480c1f1cd284a.tar.xz
ice-d1a1ef0f00e201f6bb5a90da34f480c1f1cd284a.zip
*** empty log message ***
Diffstat (limited to 'cpp/src/Freeze/TransactionI.cpp')
-rw-r--r--cpp/src/Freeze/TransactionI.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/cpp/src/Freeze/TransactionI.cpp b/cpp/src/Freeze/TransactionI.cpp
index 527062b8f0e..c40db8c8741 100644
--- a/cpp/src/Freeze/TransactionI.cpp
+++ b/cpp/src/Freeze/TransactionI.cpp
@@ -11,7 +11,10 @@
#include <Freeze/ConnectionI.h>
#include <Freeze/Exception.h>
#include <Freeze/Initialize.h>
+#include <Ice/LoggerUtil.h>
+using namespace std;
+using namespace Ice;
DbTxn*
Freeze::getTxn(const Freeze::TransactionPtr& tx)
@@ -23,13 +26,33 @@ void
Freeze::TransactionI::commit()
{
assert(_txn != 0);
+
+ long txnId;
try
{
_connection->closeAllIterators();
+
+ if(_txTrace >= 1)
+ {
+ txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
+ }
+
_txn->commit(0);
+
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "committed transaction " << hex << txnId << dec;
+ }
}
catch(const ::DbDeadlockException& dx)
{
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to commit transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
cleanup();
DeadlockException ex(__FILE__, __LINE__);
ex.message = dx.what();
@@ -37,6 +60,12 @@ Freeze::TransactionI::commit()
}
catch(const ::DbException& dx)
{
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to commit transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
cleanup();
DatabaseException ex(__FILE__, __LINE__);
ex.message = dx.what();
@@ -50,13 +79,32 @@ Freeze::TransactionI::rollback()
{
assert(_txn != 0);
+ long txnId;
try
{
_connection->closeAllIterators();
+
+ if(_txTrace >= 1)
+ {
+ txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
+ }
+
_txn->abort();
+
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "rolled back transaction " << hex << txnId << dec;
+ }
}
catch(const ::DbDeadlockException& dx)
{
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to rollback transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
cleanup();
DeadlockException ex(__FILE__, __LINE__);
ex.message = dx.what();
@@ -64,6 +112,12 @@ Freeze::TransactionI::rollback()
}
catch(const ::DbException& dx)
{
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to rollback transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
cleanup();
DatabaseException ex(__FILE__, __LINE__);
ex.message = dx.what();
@@ -74,14 +128,28 @@ Freeze::TransactionI::rollback()
Freeze::TransactionI::TransactionI(ConnectionI* connection) :
_connection(connection),
+ _txTrace(connection->txTrace()),
_txn(0)
{
try
{
_connection->dbEnv()->getEnv()->txn_begin(0, &_txn, 0);
+
+ if(_txTrace >= 1)
+ {
+ long txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "started transaction " << hex << txnId << dec;
+ }
}
catch(const ::DbException& dx)
{
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to start transaction: " << dx.what();
+ }
+
DatabaseException ex(__FILE__, __LINE__);
ex.message = dx.what();
throw ex;