Skip to content

Make parallel apply compatible with RUN_STANDALONE - #5146

Merged
SirTyson merged 2 commits into
stellar:masterfrom
SirTyson:apply-background-ledger-test-fix
Feb 25, 2026
Merged

SirTyson merged 2 commits into
stellar:masterfrom
SirTyson:apply-background-ledger-test-fix

Conversation

@SirTyson

Copy link
Copy Markdown
Contributor

Description

This change makes RUN_STANDALONE compatible with parallel ledger apply. There are a few motivations for this. First, many tests enable RUN_STANDALONE, so we silently disable parallel apply in many unit tests. This change increases test coverage (and we'll need to do it eventually anyway if we make parallel apply the unconditional default). 2nd, this allows us to use parallel apply in apply load tests, which significantly reduces variance of tests like max-sac-tps test.

This touches a few tests I'm not very familiar with (and was AI assisted), but it looks reasonable to me and CI passes, but I'd like for someone more familiar with these unit tests to take a look.

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 makes RUN_STANDALONE compatible with parallel/background ledger apply so that more unit tests (and apply-load runs) can exercise the parallel apply path.

Changes:

  • Allow RUN_STANDALONE to use PARALLEL_LEDGER_APPLY by removing the standalone restriction and updating manual-close/test flows to wait for background apply completion.
  • Prevent virtual time from advancing while background-thread actions are queued (to avoid time jumps that can delay processing apply results).
  • Adjust several tests/configs to be robust under background apply (timeouts, draining apply before shutdown, disabling parallel apply in tests that mutate headers).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/util/Timer.cpp Avoid virtual-time fast-forward when background-thread actions are pending.
src/overlay/test/TCPPeerTests.cpp Increase timeouts to account for extra main-thread callbacks under background apply.
src/main/Config.cpp Stop auto-disabling parallel apply in standalone; disable only for in-memory SQLite.
src/main/CommandLine.cpp Force parallel apply in apply-load max-sac-tps mode.
src/main/ApplicationImpl.cpp In standalone manual-close, crank until background apply finishes and LCL advances.
src/ledger/test/LedgerCloseMetaStreamTests.cpp Drain background apply before shutdown for consistent debug txset/LCL reads.
src/ledger/LedgerManagerImpl.cpp Improve test-only error for txset mismatch on background apply thread.
src/invariant/test/ConservationOfLumensTests.cpp Disable parallel apply in tests that directly mutate the ledger header.
src/history/test/HistoryTests.cpp Wait for background apply to catch up after externalization in catchup simulation.
src/herder/test/TransactionQueueTests.cpp Wait for background apply to finish before asserting queue state.
src/herder/test/HerderTests.cpp Wait for background apply to finish after externalization helper.
docs/apply-load-max-sac-tps.cfg Enable parallel apply for the max-sac-tps apply-load config.

Comment thread src/util/Timer.cpp Resolved
Comment thread src/main/ApplicationImpl.cpp Resolved
Comment thread src/main/Config.cpp Resolved
Comment thread src/overlay/test/TCPPeerTests.cpp Resolved
Comment thread src/history/test/HistoryTests.cpp Resolved
Comment thread src/herder/test/HerderTests.cpp Resolved
@SirTyson
SirTyson force-pushed the apply-background-ledger-test-fix branch from 790b206 to 576c1d6 Compare February 18, 2026 23:48

@marta-lokhova marta-lokhova 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.

Thanks, this is a helpful change! Looks good overall, I just had a couple of suggestions and a question.

Comment thread docs/apply-load-max-sac-tps.cfg Resolved
Comment thread src/util/Timer.cpp Resolved
Comment thread src/overlay/test/TCPPeerTests.cpp Resolved
@SirTyson
SirTyson force-pushed the apply-background-ledger-test-fix branch from 576c1d6 to b601bbc Compare February 19, 2026 01:29
marta-lokhova
marta-lokhova previously approved these changes Feb 19, 2026
marta-lokhova
marta-lokhova previously approved these changes Feb 20, 2026
@SirTyson
SirTyson enabled auto-merge February 20, 2026 04:08
@SirTyson
SirTyson added this pull request to the merge queue Feb 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Feb 20, 2026
@SirTyson
SirTyson added this pull request to the merge queue Feb 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Feb 20, 2026
@SirTyson
SirTyson force-pushed the apply-background-ledger-test-fix branch from 0fa5022 to e3f873f Compare February 23, 2026 03:16
marta-lokhova
marta-lokhova previously approved these changes Feb 23, 2026
@SirTyson
SirTyson added this pull request to the merge queue Feb 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Feb 23, 2026
@SirTyson
SirTyson force-pushed the apply-background-ledger-test-fix branch 4 times, most recently from 916f7e3 to d144a59 Compare February 24, 2026 23:42
@SirTyson
SirTyson force-pushed the apply-background-ledger-test-fix branch from d144a59 to 8cfc272 Compare February 25, 2026 00:45
@SirTyson
SirTyson added this pull request to the merge queue Feb 25, 2026
Merged via the queue into stellar:master with commit 4318e17 Feb 25, 2026
51 checks passed
@SirTyson
SirTyson deleted the apply-background-ledger-test-fix branch February 25, 2026 08:53
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