Skip to content

Fix race in persist publish queue - #5240

Merged
SirTyson merged 1 commit into
stellar:masterfrom
SirTyson:fix-race-publish-test
Apr 21, 2026
Merged

SirTyson merged 1 commit into
stellar:masterfrom
SirTyson:fix-race-publish-test

Conversation

@SirTyson

Copy link
Copy Markdown
Contributor

Description

Fixes a race in "persist publish queue" tests.

Here is a diff to repro the original failure:

  diff --git a/src/ledger/LedgerManagerImpl.cpp b/src/ledger/LedgerManagerImpl.cpp
  index b4dd5ee19..5f1fc9a18 100644
  --- a/src/ledger/LedgerManagerImpl.cpp
  +++ b/src/ledger/LedgerManagerImpl.cpp
  @@ -2934,6 +2934,7 @@ LedgerManagerImpl::storePersistentStateAndLedgerHeaderInDB(

       if (appendToCheckpoint)
       {
  +        std::this_thread::sleep_for(std::chrono::milliseconds(2000));
           mApp.getHistoryManager().appendLedgerHeader(header);
       }

I think this issue is from #5229. We used to purge SCP state in newSlotExternalized, but now it get's called post apply. while (hm1.getPublishSuccessCount() < 5) was a bad check, since we could increment the published count before hitting the SCP message cleanup. I think the race existed for a while, but the most recent PR delayed cleanup, so it made it more likely to occur. The race seems like it's just in the test itself.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a race/flakiness in the "persist publish queue" history publishing acceptance test by waiting not only for publish completion, but also for SCP history trimming to have progressed past the expected range.

Changes:

  • Replace a publish-success-only busy wait with testutil::crankUntil(...) plus an additional predicate checking SCP history trimming progress.
  • Add a small helper query (SELECT MIN(ledgerseq) FROM scphistory) to verify trimming has caught up before asserting on trimmed history.
  • Clarify the test comment to explicitly refer to “SCP history”.

@SirTyson
SirTyson added this pull request to the merge queue Apr 21, 2026
Merged via the queue into stellar:master with commit c96bf6a Apr 21, 2026
71 checks passed
@SirTyson
SirTyson deleted the fix-race-publish-test branch April 21, 2026 18:34
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.

3 participants