Skip to content

LedgerManager, LedgerTxn tech debt #4725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marta-lokhova
Copy link
Contributor

Resolves #4592

@marta-lokhova marta-lokhova force-pushed the ledgerCloseTechDebt branch from e053306 to c9fb8ab Compare May 12, 2025 23:17
Copy link
Contributor

@graydon graydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good, but a few questions noted inline.

Comment on lines +2343 to +2347
if (mLedgerApplyManager.isApplying())
{
trackingHeartBeat();
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this branch on isApplying is new; it's an assert before. is this correct? I can't really follow all the places this gets triggered.

.copySearchableLiveBucketListSnapshot();
}
releaseAssert(threadIsMain());
releaseAssert(getLCLState().snapshot);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Did no callers of this rely on the previous lazy population?

@@ -1496,12 +1348,8 @@ LedgerManagerImpl::maybeResetLedgerCloseMetaDebugStream(uint32_t ledgerSeq)
SearchableSnapshotConstPtr
LedgerManagerImpl::getLastClosedSnaphot()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LedgerManagerImpl::getLastClosedSnaphot()
LedgerManagerImpl::getLastClosedSnapshot()

Comment on lines +2630 to +2637
ThreadInvariant::throwIfWrongThread() const
{
std::lock_guard<std::recursive_mutex> guard(mThreadInvariantMutex);
if (mActiveThreadIdSet && mThreadID != std::this_thread::get_id())
{
throw std::runtime_error("ThreadInvariant called from wrong thread");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not complaining about this, but curious: taking a mutex and doing a TLS access on every single method in this class might show up in profiles, considering how hot the ltx sometimes is; does it?

Comment on lines +1657 to +1658
// `commit` and `rollback` terminate the program on an exception,
// because they are marked noexcept SECTION("commit child")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is somewhat worrying. Or rather: I wonder if the thread-invariant error ought to just be an abort in all cases, rather than an exception? the ltx is exception safe because transactions run in an exception-catch block and use exceptions for "meaningfully recoverable" errors. But a thread-safety violation isn't really recoverable, right? It should probably always be fatal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post parallel ledger close cleanup
2 participants