Skip to content

Commit 3620e88

Browse files
authored
Fix race condition in rebuildInMemorySorobanStateForTesting (#5351)
# Description Fixes a flaky test I think I ran into on an unrelated [PR](https://github.com/stellar/stellar-core/actions/runs/29378709185/job/87327140083?pr=5350). It looks like we can call the test only module cache rebuild function while a real, background module cache build is under way, causing an assert failure. This just makes sure we finish any in-progress builds before calling the test reset function. # Checklist - [x] Reviewed the [contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes) document - [x] Rebased on top of master (no merge commits) - [x] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio extension) - [x] Compiles - [x] Ran all tests - [ ] If change impacts performance, include supporting evidence per the [performance document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
2 parents a711c1d + 911fa91 commit 3620e88

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/ledger/LedgerManagerImpl.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,13 @@ LedgerManagerImpl::getInMemorySorobanStateForTesting()
896896
void
897897
LedgerManagerImpl::rebuildInMemorySorobanStateForTesting(uint32_t ledgerVersion)
898898
{
899+
// Make sure we don't race on an in-progress compilation.
900+
if (mApplyState.isCompilationRunning())
901+
{
902+
mApplyState.finishPendingCompilation();
903+
mApplyState.markEndOfSetupPhase();
904+
}
905+
899906
mApplyState.resetToSetupPhase();
900907
mApplyState.getInMemorySorobanStateForTesting().clearForTesting();
901908
mApplyState.populateInMemorySorobanState();

0 commit comments

Comments
 (0)