more infos for finding dead lock

This commit is contained in:
Dario 2019-12-07 08:12:24 +01:00
parent 75038be86a
commit 03804ed24a
5 changed files with 20 additions and 9 deletions

View File

@ -274,8 +274,8 @@ int HandleElopageRequestTask::run()
// if user exist we can stop now
if (getUserIdFromDB()) {
addError(param_error_order_id);
sendErrorsAsEmail();
//addError(param_error_order_id);
//sendErrorsAsEmail();
return -2;
}

View File

@ -6,15 +6,23 @@ namespace UniLib {
void MultithreadContainer::lock(const char* stackDetails/* = nullptr*/)
{
const static char* functionName = "MultithreadContainer::lock";
try {
mWorkMutex.lock(500);
if (stackDetails) {
mLastSucceededLock = stackDetails;
}
}
catch (Poco::TimeoutException& ex) {
ErrorList errors;
if (stackDetails) {
errors.addError(new Error("MultithreadContainer::lock", stackDetails));
errors.addError(new ParamError(functionName, "lock timeout", ex.displayText()));
if (mLastSucceededLock != "") {
errors.addError(new ParamError(functionName, "last succeed lock by ", mLastSucceededLock.data()));
}
errors.addError(new ParamError("MultithreadContainer::lock", "lock timeout", ex.displayText()));
if (stackDetails) {
errors.addError(new Error(functionName, stackDetails));
}
errors.sendErrorsAsEmail();
}
}

View File

@ -44,10 +44,11 @@ namespace UniLib {
void lock(const char* stackDetails = nullptr);
inline void unlock() {mWorkMutex.unlock();}
inline void unlock() { mLastSucceededLock = ""; mWorkMutex.unlock(); }
protected:
private:
Poco::Mutex mWorkMutex;
std::string mLastSucceededLock;
};
}
}

View File

@ -1,6 +1,6 @@
#include "TransactionTransfer.h"
const std::string TransactionTransfer::mInvalidIndexMessage("invalid index");
TransactionTransfer::KontoTableEntry::KontoTableEntry(User* user, google::protobuf::int64 amount, bool negativeAmount/* = false*/)
{
@ -133,10 +133,11 @@ int TransactionTransfer::prepare()
const std::string& TransactionTransfer::getKontoNameCell(int index)
{
lock();
if (index >= mKontoTable.size()) {
unlock();
return "invalid index";
return mInvalidIndexMessage;
}
unlock();
@ -147,7 +148,7 @@ const std::string& TransactionTransfer::getAmountCell(int index)
lock();
if (index >= mKontoTable.size()) {
unlock();
return "invalid index";
return mInvalidIndexMessage;
}
unlock();

View File

@ -27,6 +27,7 @@ public:
const std::string& getAmountCell(int index);
protected:
const static std::string mInvalidIndexMessage;
struct KontoTableEntry {
public:
KontoTableEntry(User* user, google::protobuf::int64 amount, bool negativeAmount = false);