Skip to content

Commit 54a9c76

Browse files
authored
Change some fatal asserts to just throws that become internal errors (#4814)
A bunch of new asserts I added in ParallelApplyUtils.cpp are really nonfatal / should probably just abort the tx with an internal error.
2 parents 5dcbb78 + 39b164a commit 54a9c76

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/transactions/ParallelApplyUtils.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ GlobalParallelApplyLedgerState::commitChangesToLedgerTxn(
455455
{
456456
auto it =
457457
mGlobalRestoredEntries.hotArchive.find(getTTLKey(kvp.first));
458-
releaseAssert(it != mGlobalRestoredEntries.hotArchive.end());
458+
releaseAssertOrThrow(it != mGlobalRestoredEntries.hotArchive.end());
459459
ltxInner.markRestoredFromHotArchive(kvp.second, it->second);
460460
}
461461
}
@@ -482,7 +482,7 @@ GlobalParallelApplyLedgerState::getLiveEntryOpt(LedgerKey const& key) const
482482
}
483483
// Invariant check: if an entry is not in mGlobalEntryMap it should also not
484484
// be in the restored map.
485-
releaseAssert(!mGlobalRestoredEntries.entryWasRestored(key));
485+
releaseAssertOrThrow(!mGlobalRestoredEntries.entryWasRestored(key));
486486

487487
// Check InMemorySorobanState cache for soroban types
488488
std::shared_ptr<LedgerEntry const> res;
@@ -652,8 +652,8 @@ ThreadParallelApplyLedgerState::flushRoTTLBumpsInTxWriteFootprint(
652652
// the entry must exist. If it was deleted, we would've
653653
// erased the TTL key from mRoTTLBumps.
654654
auto ttlEntry = getLiveEntryOpt(ttlKey);
655-
releaseAssert(ttlEntry);
656-
releaseAssert(ttl(ttlEntry) <= b->second);
655+
releaseAssertOrThrow(ttlEntry);
656+
releaseAssertOrThrow(ttl(ttlEntry) <= b->second);
657657
ttl(ttlEntry) = b->second;
658658
upsertEntry(ttlKey, ttlEntry.value());
659659
mRoTTLBumps.erase(b);
@@ -669,7 +669,7 @@ ThreadParallelApplyLedgerState::flushRemainingRoTTLBumps()
669669
auto entryOpt = getLiveEntryOpt(lk);
670670
// The entry should always exist. If the entry was deleted,
671671
// then we would've erased the TTL key from roTTLBumps.
672-
releaseAssert(entryOpt);
672+
releaseAssertOrThrow(entryOpt);
673673
if (ttl(entryOpt) < ttlBump)
674674
{
675675
auto updated = entryOpt.value();
@@ -706,12 +706,12 @@ ThreadParallelApplyLedgerState::getLiveEntryOpt(LedgerKey const& key) const
706706
// associated entry was live-restored.
707707
if (key.type() == TTL)
708708
{
709-
releaseAssert(!mThreadRestoredEntries.entryWasRestoredFromMap(
709+
releaseAssertOrThrow(!mThreadRestoredEntries.entryWasRestoredFromMap(
710710
key, mThreadRestoredEntries.hotArchive));
711711
}
712712
else
713713
{
714-
releaseAssert(!mThreadRestoredEntries.entryWasRestored(key));
714+
releaseAssertOrThrow(!mThreadRestoredEntries.entryWasRestored(key));
715715
}
716716

717717
// Check InMemorySorobanState cache for soroban types
@@ -749,7 +749,7 @@ ThreadParallelApplyLedgerState::commitChangeFromSuccessfulOp(
749749
if (entryOpt && oldEntryOpt && roTTLSet.find(key) != roTTLSet.end())
750750
{
751751
// Accumulate RO bumps instead of writing them to the entryMap.
752-
releaseAssert(ttl(entryOpt) >= ttl(oldEntryOpt));
752+
releaseAssertOrThrow(ttl(entryOpt) >= ttl(oldEntryOpt));
753753
updateMaxOfRoTTLBump(mRoTTLBumps, key, entryOpt);
754754
}
755755
else if (entryOpt)
@@ -767,7 +767,7 @@ ThreadParallelApplyLedgerState::setEffectsDeltaFromSuccessfulOp(
767767
ParallelTxReturnVal const& res, ParallelLedgerInfo const& ledgerInfo,
768768
TxEffects& effects) const
769769
{
770-
releaseAssert(res.getSuccess());
770+
releaseAssertOrThrow(res.getSuccess());
771771
for (auto const& [lk, le] : res.getModifiedEntryMap())
772772
{
773773
auto prevLe = getLiveEntryOpt(lk);
@@ -807,7 +807,7 @@ void
807807
ThreadParallelApplyLedgerState::commitChangesFromSuccessfulOp(
808808
ParallelTxReturnVal const& res, TxBundle const& txBundle)
809809
{
810-
releaseAssert(res.getSuccess());
810+
releaseAssertOrThrow(res.getSuccess());
811811
auto roTTLSet = buildRoTTLSet(txBundle);
812812
for (auto const& [key, entryOpt] : res.getModifiedEntryMap())
813813
{

0 commit comments

Comments
 (0)