Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add idempotent mode for new-hist#5216

Draft
Copilot wants to merge 2 commits into
master from
copilot/add-idempotent-initialization-flag
Draft

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

Conversation

Copilot AI commented Apr 9, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

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
@anupsdf anupsdf requested review from sisuresh and removed request for anupsdf April 16, 2026 21:10
ws.executeWork<GetHistoryArchiveStateWork>(0, archive, "hist-init", 0);
if (getHas->getState() == BasicWork::State::WORK_SUCCESS)
{
if (idempotent)

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.

Is the implication that if the archive has already been initialized, it is valid? What if the archives are for a different network like pubnet vs testnet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sisuresh sisuresh sisuresh left review comments

Copilot code review Copilot Awaiting requested review from Copilot Copilot will automatically review once the pull request is marked ready for review

At least 1 approving review is required to merge this pull request.

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Provide idempotent way to initialize history archive

AltStyle によって変換されたページ (->オリジナル) /