Skip to content

Commit

Permalink
Log InboundLedgers mutex.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrippled committed Aug 21, 2024
1 parent 49e2428 commit c6d0e44
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/xrpld/app/ledger/detail/InboundLedger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ InboundLedger::init(ScopedLockType& collectionLock)
JLOG(journal_.debug()) << "TimeoutCounter lock2 " << this;
ScopedLockType sl(mtx_);
collectionLock.unlock();

JLOG(journal_.debug()) << "InboundLedgers InboundLedger::init unlock";
tryDB(app_.getNodeFamily().db());
if (failed_)
{
Expand Down
41 changes: 36 additions & 5 deletions src/xrpld/app/ledger/detail/InboundLedgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ class InboundLedgersImp : public InboundLedgers
std::shared_ptr<InboundLedger> inbound;
{
JLOG(j_.debug()) << "InboundLedgers::acquire3 " << this;
JLOG(j_.debug()) << "InboundLedgers lock1";
ScopedLockType sl(mLock);
JLOG(j_.debug()) << "InboundLedgers::acquire4 " << this;
if (stopping_)
{
JLOG(j_.debug()) << "InboundLedgers::acquire5 " << this;
JLOG(j_.debug()) << "InboundLedgers unlock1-1";
return {};
}

Expand Down Expand Up @@ -116,6 +118,7 @@ class InboundLedgersImp : public InboundLedgers
if (inbound->isFailed())
{
JLOG(j_.debug()) << "InboundLedgers::acquire6 " << this;
JLOG(j_.debug()) << "InboundLedgers unlock1-2 but I think init already unlocked";
return {};
}

Expand All @@ -127,10 +130,12 @@ class InboundLedgersImp : public InboundLedgers
if (!inbound->isComplete())
{
JLOG(j_.debug()) << "InboundLedgers::acquire7 " << this;
JLOG(j_.debug()) << "InboundLedgers unlock1-3 but I think init already unlocked";
return {};
}

JLOG(j_.debug()) << "InboundLedgers::acquire8 " << this;
JLOG(j_.debug()) << "InboundLedgers unlock1-4 but I think init already unlocked";
return inbound->getLedger();
}

Expand All @@ -142,6 +147,7 @@ class InboundLedgersImp : public InboundLedgers
std::shared_ptr<InboundLedger> ret;

{
JLOG(j_.debug()) << "InboundLedgers lock2";
ScopedLockType sl(mLock);

auto it = mLedgers.find(hash);
Expand All @@ -150,6 +156,7 @@ class InboundLedgersImp : public InboundLedgers
ret = it->second;
}
}
JLOG(j_.debug()) << "InboundLedgers unlock2";

return ret;
}
Expand Down Expand Up @@ -213,18 +220,26 @@ class InboundLedgersImp : public InboundLedgers
void
logFailure(uint256 const& h, std::uint32_t seq) override
{
JLOG(j_.debug()) << "InboundLedgers lock3";
ScopedLockType sl(mLock);

mRecentFailures.emplace(h, seq);
JLOG(j_.debug()) << "InboundLedgers unlock3";
}

bool
isFailure(uint256 const& h) override
{
ScopedLockType sl(mLock);
bool ret;
JLOG(j_.debug()) << "InboundLedgers lock4";
{
ScopedLockType sl(mLock);

beast::expire(mRecentFailures, kReacquireInterval);
return mRecentFailures.find(h) != mRecentFailures.end();
beast::expire(mRecentFailures, kReacquireInterval);
ret = mRecentFailures.find(h) != mRecentFailures.end();
}
JLOG(j_.debug()) << "InboundLedgers unlock4";
return ret;
}

/** We got some data for a ledger we are no longer acquiring Since we paid
Expand Down Expand Up @@ -268,10 +283,12 @@ class InboundLedgersImp : public InboundLedgers
void
clearFailures() override
{
JLOG(j_.debug()) << "InboundLedgers lock5";
ScopedLockType sl(mLock);

mRecentFailures.clear();
mLedgers.clear();
JLOG(j_.debug()) << "InboundLedgers unlock5";
}

std::size_t
Expand All @@ -298,6 +315,7 @@ class InboundLedgersImp : public InboundLedgers
std::vector<std::pair<uint256, std::shared_ptr<InboundLedger>>> acqs;

{
JLOG(j_.debug()) << "InboundLedgers lock6";
ScopedLockType sl(mLock);

acqs.reserve(mLedgers.size());
Expand All @@ -314,6 +332,7 @@ class InboundLedgersImp : public InboundLedgers
ret[to_string(it.first)][jss::failed] = true;
}
}
JLOG(j_.debug()) << "InboundLedgers unlock6";

for (auto const& it : acqs)
{
Expand All @@ -333,6 +352,7 @@ class InboundLedgersImp : public InboundLedgers
{
std::vector<std::shared_ptr<InboundLedger>> acquires;
{
JLOG(j_.debug()) << "InboundLedgers lock7";
ScopedLockType sl(mLock);

acquires.reserve(mLedgers.size());
Expand All @@ -342,6 +362,7 @@ class InboundLedgersImp : public InboundLedgers
acquires.push_back(it.second);
}
}
JLOG(j_.debug()) << "InboundLedgers lock7";

for (auto const& acquire : acquires)
{
Expand All @@ -359,6 +380,7 @@ class InboundLedgersImp : public InboundLedgers
std::size_t total;

{
JLOG(j_.debug()) << "InboundLedgers lock8";
ScopedLockType sl(mLock);
MapType::iterator it(mLedgers.begin());
total = mLedgers.size();
Expand Down Expand Up @@ -389,6 +411,7 @@ class InboundLedgersImp : public InboundLedgers

beast::expire(mRecentFailures, kReacquireInterval);
}
JLOG(j_.debug()) << "InboundLedgers unlock8";

JLOG(j_.debug())
<< "Swept " << stuffToSweep.size() << " out of " << total
Expand All @@ -402,17 +425,25 @@ class InboundLedgersImp : public InboundLedgers
void
stop() override
{
JLOG(j_.debug()) << "InboundLedgers lock9";
ScopedLockType lock(mLock);
stopping_ = true;
mLedgers.clear();
mRecentFailures.clear();
JLOG(j_.debug()) << "InboundLedgers unlock9";
}

std::size_t
cacheSize() override
{
ScopedLockType lock(mLock);
return mLedgers.size();
std::size_t ret;
JLOG(j_.debug()) << "InboundLedgers lock10";
{
ScopedLockType lock(mLock);
ret = mLedgers.size();
}
JLOG(j_.debug()) << "InboundLedgers unlock10";
return ret;
}

private:
Expand Down

0 comments on commit c6d0e44

Please sign in to comment.