Skip to content

Add idempotent mode for new-hist#5216

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-idempotent-initialization-flag
Draft

Add idempotent mode for new-hist#5216
Copilot wants to merge 2 commits intomasterfrom
copilot/add-idempotent-initialization-flag

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

new-hist currently fails if the target history archive is already initialized, which makes repeated startup workflows awkward in dynamic environments. This change adds an explicit idempotent mode so operators can safely run archive initialization multiple times.

  • CLI

    • Adds --idempotent to stellar-core new-hist
    • Preserves existing behavior by default; repeated initialization still fails unless the flag is set
  • History archive initialization

    • Threads the idempotent option from command-line handling into initializeHistories(...)
    • Extends HistoryArchiveManager::initializeHistoryArchive(...) with an idempotent mode
    • Treats an existing .well-known/stellar-history.json as success when idempotent mode is enabled
  • Coverage

    • Adds a focused history test that verifies:
      • first initialization succeeds
      • second initialization succeeds when idempotent mode is requested
      • existing non-idempotent behavior remains unchanged
  • Docs

    • Updates the command reference for new-hist to document --idempotent

Example:

stellar-core new-hist --idempotent my-archive

This allows startup automation to ensure a history archive exists without needing wrapper logic to suppress an expected “already initialized” failure.

Agent-Logs-Url: https://github.com/stellar/stellar-core/sessions/9dfeca7f-4f5c-412a-9a88-f98dc0c3aca7

Co-authored-by: anupsdf <127880479+anupsdf@users.noreply.github.com>
Copilot AI changed the title [WIP] Add idempotent way to initialize history archive Add idempotent mode for new-hist Apr 9, 2026
Copilot AI requested a review from anupsdf April 9, 2026 22:52
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.

Provide idempotent way to initialize history archive

2 participants