Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services/horizon: Update cursor when bumping ledger to latest #4150

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented Dec 22, 2021

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've updated the relevant CHANGELOG (here for Horizon) if
    needed with deprecations, added features, breaking changes, and DB schema changes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

Update cursor in Stellar-Core to latest ingested ledger when local ingestion is behind the cluster.

Why

If there is a DB ingesting instance more than one ingesting instance: either Captive-Core or DB connected to another Stellar-Core, it's possible that the cursor will be updated very rarely. This will make the Stellar-Core DB size bloat as the old ledger will not be removed.

Known limitations

[TODO or N/A]

@bartekn bartekn requested a review from a team December 22, 2021 15:58
@@ -416,6 +416,14 @@ func (r resumeState) run(s *system) (transition, error) {
log.WithField("ingestLedger", ingestLedger).
WithField("lastIngestedLedger", lastIngestedLedger).
Info("bumping ingest ledger to next ledger after ingested ledger in db")

// Update cursor if there's more than one ingesting instance: either
Copy link
Contributor

Choose a reason for hiding this comment

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

ingestLedger <= lastIngestedLedger is a state that can only happen due to multiple ingestions instances? just wanted to understand the comment which refers to it, would a single ingestion instance ever get in here, i.e. this is a best effort attempt under any case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, this can only happen if there is more than one ingesting instance. ingestLedger is the currently ingested ledger in this instance, lastIngestedLedger is the last ingested ledger in the cluster. I guess the variable names could be better.

Copy link
Contributor

@sreuland sreuland left a comment

Choose a reason for hiding this comment

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

nice test coverage too!

@bartekn bartekn merged commit d33088d into stellar:master Jan 10, 2022
@bartekn bartekn deleted the update-cursor-behind branch January 10, 2022 20:45
Copy link

@eliane345 eliane345 left a comment

Choose a reason for hiding this comment

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

Desculpe pelo transtorno

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.

4 participants