Skip to content

Clarify background ledger apply flow in comments and rename some variables - #5432

Merged
marta-lokhova merged 3 commits into
stellar:masterfrom
marta-lokhova:clarifyBackgroundLedgerApplyFlow
Aug 28, 2026
Merged

marta-lokhova merged 3 commits into
stellar:masterfrom
marta-lokhova:clarifyBackgroundLedgerApplyFlow

Conversation

@marta-lokhova

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings August 26, 2026 23:06

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

Renames ledger-close internals to reflect the background ledger-apply pipeline and clarifies state ownership and completion flow.

Changes:

  • Renames apply-thread APIs, configuration helpers, and buffered-ledger state.
  • Renames ledger completion methods and test hooks.
  • Expands concurrency and ledger-state documentation.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/util/test/TimerTests.cpp Updates apply-thread API usage.
src/transactions/TransactionFrameBase.h Revises parallel-apply documentation.
src/main/Config.h Renames and documents the configuration predicate.
src/main/Config.cpp Implements the renamed predicate.
src/main/Application.h Renames apply-thread interfaces.
src/main/ApplicationImpl.h Renames apply-thread members.
src/main/ApplicationImpl.cpp Updates thread lifecycle and dispatch implementation.
src/ledger/LedgerTxn.cpp Uses the renamed configuration predicate.
src/ledger/LedgerManager.h Documents pipeline states and renames completion API.
src/ledger/LedgerManagerImpl.h Renames completion members and adds locking notes.
src/ledger/LedgerManagerImpl.cpp Renames completion flow and expands concurrency documentation.
src/history/test/HistoryTests.cpp Updates buffered-ledger terminology.
src/history/HistoryManager.h Updates buffered-ledger reference.
src/herder/test/HerderTests.cpp Updates completion hook and comments.
src/herder/HerderImpl.cpp Uses the renamed configuration predicate.
src/catchup/LedgerApplyManagerImpl.h Renames buffered-ledger state and helpers.
src/catchup/LedgerApplyManagerImpl.cpp Applies buffered-ledger and apply-thread renames.
src/catchup/CatchupWork.cpp Updates buffered-ledger comments.
Suppressed comments (1)

src/ledger/LedgerManagerImpl.cpp:1636

  • This second reference also uses the retired ledger-close thread terminology. It should use ledger apply so the stated invariant matches mLedgerApplyThread and the rest of the updated comment.
//  * Application is strictly serialized: there is exactly one ledger-close

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/ledger/LedgerManagerImpl.h Resolved
Comment thread src/ledger/LedgerManagerImpl.h Resolved
Comment thread src/ledger/LedgerManagerImpl.cpp Resolved
Comment thread src/ledger/LedgerManagerImpl.cpp Resolved
Comment thread src/herder/test/HerderTests.cpp Resolved
Comment thread src/catchup/LedgerApplyManagerImpl.h Resolved
Comment thread src/history/HistoryManager.h Resolved
Comment thread src/transactions/TransactionFrameBase.h Resolved
Comment thread src/catchup/LedgerApplyManagerImpl.h Resolved
@marta-lokhova
marta-lokhova force-pushed the clarifyBackgroundLedgerApplyFlow branch from b6db839 to 9dea237 Compare August 26, 2026 23:13

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

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.

Comment thread src/history/HistoryManager.h Resolved
Comment thread src/ledger/LedgerManagerImpl.h Resolved
Comment thread src/ledger/LedgerManagerImpl.cpp Resolved
Comment thread src/catchup/LedgerApplyManagerImpl.h Resolved
@marta-lokhova
marta-lokhova force-pushed the clarifyBackgroundLedgerApplyFlow branch from 76cdbf3 to 11f38d3 Compare August 26, 2026 23:37
Copilot AI review requested due to automatic review settings August 27, 2026 18:49

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

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Comment thread src/ledger/LedgerManager.h Resolved
Comment thread src/herder/test/HerderTests.cpp Resolved
@marta-lokhova
marta-lokhova force-pushed the clarifyBackgroundLedgerApplyFlow branch from f3bf40e to b182899 Compare August 27, 2026 20:54
Copilot AI review requested due to automatic review settings August 27, 2026 20:54

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

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread src/ledger/LedgerManagerImpl.cpp Resolved
Copilot AI review requested due to automatic review settings August 27, 2026 21:27
@marta-lokhova
marta-lokhova force-pushed the clarifyBackgroundLedgerApplyFlow branch from b182899 to a3bf440 Compare August 27, 2026 21:27

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

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Suppressed comments (1)

src/ledger/LedgerManagerImpl.cpp:1567

  • This safety claim overlooks publishSorobanMetrics(), which accesses mApplyState and drains SorobanMetrics batches from the main thread. With the newly documented pipeline, applyLedger(N+1) can concurrently obtain a batch reference and mutate it after flushApplyMetricsBatches() moves and destroys that batch; ledger-wide atomics can also be reset while N+1 increments them. This is a concrete data race and can lose/corrupt metrics or dereference freed storage. Snapshot/publish ledger N's metrics before the apply thread starts N+1, or make batch draining and mutation properly synchronized before describing completion as safe.
// safe here because every input is one of:
//  * appliedLedgerState: an immutable snapshot shared with ApplyState; both
//    threads may read it concurrently, while neither mutates it;
//  * main-thread-only state: mCurrentlyApplyingLedger, the LM state machine,
//    Herder notification.

Comment thread src/transactions/TransactionFrameBase.h Resolved
Comment thread src/catchup/LedgerApplyManagerImpl.h Resolved
Comment thread src/ledger/LedgerManager.h Resolved
Comment thread src/ledger/LedgerManagerImpl.cpp Resolved

@dmkozh dmkozh 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 looks much more clear than what we had (though I'm admittedly a bit biased as I've just had a refresher on how this is supposed to work, so it might seem more clear than it would have been 2 days ago).

@marta-lokhova
marta-lokhova added this pull request to the merge queue Aug 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 28, 2026
@marta-lokhova
marta-lokhova added this pull request to the merge queue Aug 28, 2026
Merged via the queue into stellar:master with commit 9020c27 Aug 28, 2026
56 checks passed
@marta-lokhova
marta-lokhova deleted the clarifyBackgroundLedgerApplyFlow branch August 28, 2026 18:02
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