summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/Freeze/ConnectionI.cpp1
-rw-r--r--cpp/src/Freeze/ConnectionI.h10
-rw-r--r--cpp/src/Freeze/EvictorI.cpp49
-rw-r--r--cpp/src/Freeze/EvictorI.h2
-rw-r--r--cpp/src/Freeze/TransactionI.cpp68
-rw-r--r--cpp/src/Freeze/TransactionI.h1
6 files changed, 130 insertions, 1 deletions
diff --git a/cpp/src/Freeze/ConnectionI.cpp b/cpp/src/Freeze/ConnectionI.cpp
index c64b326b19d..b847a904ed8 100644
--- a/cpp/src/Freeze/ConnectionI.cpp
+++ b/cpp/src/Freeze/ConnectionI.cpp
@@ -84,6 +84,7 @@ Freeze::ConnectionI::ConnectionI(const CommunicatorPtr& communicator,
_dbEnv(SharedDbEnv::get(communicator, envName, dbEnv)),
_envName(envName),
_trace(communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Map")),
+ _txTrace(communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Transaction")),
_deadlockWarning(communicator->getProperties()->getPropertyAsInt("Freeze.Warn.Deadlocks") != 0)
{
}
diff --git a/cpp/src/Freeze/ConnectionI.h b/cpp/src/Freeze/ConnectionI.h
index e801019f33e..9868abe5ba7 100644
--- a/cpp/src/Freeze/ConnectionI.h
+++ b/cpp/src/Freeze/ConnectionI.h
@@ -72,6 +72,9 @@ public:
Ice::Int
trace() const;
+ Ice::Int
+ txTrace() const;
+
bool
deadlockWarning() const;
@@ -83,6 +86,7 @@ private:
TransactionIPtr _transaction;
std::list<MapHelperI*> _mapList;
Ice::Int _trace;
+ Ice::Int _txTrace;
bool _deadlockWarning;
};
@@ -129,6 +133,12 @@ ConnectionI::trace() const
return _trace;
}
+inline Ice::Int
+ConnectionI::txTrace() const
+{
+ return _txTrace;
+}
+
inline bool
ConnectionI::deadlockWarning() const
{
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp
index d9957034140..bc6d7de6268 100644
--- a/cpp/src/Freeze/EvictorI.cpp
+++ b/cpp/src/Freeze/EvictorI.cpp
@@ -288,9 +288,11 @@ Freeze::EvictorI::EvictorI(const ObjectAdapterPtr& adapter,
_filename(filename),
_createDb(createDb),
_trace(0),
+ _txTrace(0),
_pingObject(new PingObject)
{
_trace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Evictor");
+ _txTrace = _communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Transaction");
_deadlockWarning = (_communicator->getProperties()->getPropertyAsInt("Freeze.Warn.Deadlocks") != 0);
string propertyPrefix = string("Freeze.Evictor.") + envName + '.' + _filename;
@@ -701,7 +703,7 @@ Freeze::EvictorI::createObject(const Identity& ident, const ObjectPtr& servant)
if(_trace >= 1)
{
Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "added object \"" << _communicator->identityToString(ident) << "\"";
+ out << "added or updated object \"" << _communicator->identityToString(ident) << "\"";
}
}
@@ -1190,6 +1192,11 @@ Freeze::EvictorI::locateImpl(const Current& current, LocalObjectPtr& cookie)
ObjectStore* store = findStore(current.facet);
if(store == 0)
{
+ if(_trace >= 2)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate could not find a database for facet \"" << current.facet << "\"";
+ }
return 0;
}
@@ -1198,6 +1205,12 @@ Freeze::EvictorI::locateImpl(const Current& current, LocalObjectPtr& cookie)
EvictorElementPtr element = store->pin(current.id);
if(element == 0)
{
+ if(_trace >= 2)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate could not find \"" << _communicator->identityToString(current.id) << "\" in database \""
+ << current.facet << "\"";
+ }
return 0;
}
@@ -1215,12 +1228,25 @@ Freeze::EvictorI::locateImpl(const Current& current, LocalObjectPtr& cookie)
IceUtil::Mutex::Lock lockElement(element->mutex);
if(element->status == EvictorElement::destroyed || element->status == EvictorElement::dead)
{
+ if(_trace >= 2)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate found \"" << _communicator->identityToString(current.id)
+ << "\" in the cache for database \"" << current.facet << "\" but it was dead or destroyed";
+ }
return 0;
}
//
// It's a good one!
//
+ if(_trace >= 2)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate found \"" << _communicator->identityToString(current.id) << "\" in database \""
+ << current.facet << "\"";
+ }
+
fixEvictPosition(element);
element->usageCount++;
cookie = element;
@@ -1593,6 +1619,15 @@ Freeze::EvictorI::run()
{
DbTxn* tx = 0;
_dbEnv->getEnv()->txn_begin(0, &tx, 0);
+
+ long txnId;
+ if(_txTrace >= 1)
+ {
+ txnId = (tx->id() & 0x7FFFFFFF) + 0x80000000L;
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "started transaction " << hex << txnId << dec << " in saving thread";
+ }
+
try
{
for(size_t i = 0; i < txSize; i++)
@@ -1604,9 +1639,21 @@ Freeze::EvictorI::run()
catch(...)
{
tx->abort();
+ if(_txTrace >= 1)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "rolled back transaction " << hex << txnId << dec;
+ }
throw;
}
tx->commit(0);
+
+ if(_txTrace >= 1)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "committed transaction " << hex << txnId << dec;
+ }
+
streamedObjectQueue.erase
(streamedObjectQueue.begin(),
streamedObjectQueue.begin() + txSize);
diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h
index 0a6cb4fced7..8b845bc773c 100644
--- a/cpp/src/Freeze/EvictorI.h
+++ b/cpp/src/Freeze/EvictorI.h
@@ -158,6 +158,7 @@ public:
bool deadlockWarning() const;
Ice::Int trace() const;
+ Ice::Int txTrace() const;
void initialize(const Ice::Identity&, const std::string&, const Ice::ObjectPtr&);
@@ -227,6 +228,7 @@ private:
bool _createDb;
Ice::Int _trace;
+ Ice::Int _txTrace;
//
// Threads that have requested a "saveNow" and are waiting for
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;
diff --git a/cpp/src/Freeze/TransactionI.h b/cpp/src/Freeze/TransactionI.h
index 914e8ec5f6d..acb9f9e8892 100644
--- a/cpp/src/Freeze/TransactionI.h
+++ b/cpp/src/Freeze/TransactionI.h
@@ -45,6 +45,7 @@ private:
cleanup();
ConnectionIPtr _connection;
+ Ice::Int _txTrace;
DbTxn* _txn;
};