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/internal/actions: Wrap SSE handlers in repeatable read tx #2344

Merged
merged 3 commits into from
Mar 6, 2020

Conversation

tamirms
Copy link
Contributor

@tamirms tamirms commented Feb 28, 2020

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

  • Execute SSE handlers in repeatable read transactions
  • Obtain account info from stellar core db using repeatable read transaction

Why

Close #2331

I noticed Some extra balances error in /accounts/{id} stream. At first, I thought that it was the inconsistency issue propagated from stellar-core (we build Account object using a few DB queries without REPEATABLE READ transaction). But then I realized that we don't use REPEATABLE READ transaction in Horizon DB while streaming.

We should update the streaming code to start a REPEATABLE READ transaction (if not in a transaction already) before calling an action function and then rollback (only if not in a previously started transaction).

...

We've seen another instance today for non-streaming request and the reason is getting data from core in multiple requests. So we should probably add start a new REPEATABLE READ transaction when getting data from Stellar-Core.

Known limitations

[N/A]

@cla-bot cla-bot bot added the cla: yes label Feb 28, 2020
@tamirms tamirms changed the base branch from master to release-horizon-v1.1.0 February 28, 2020 20:19
@tamirms tamirms requested review from bartekn and abuiles February 28, 2020 20:20
Copy link
Contributor

@abuiles abuiles left a comment

Choose a reason for hiding this comment

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

👍

}

return func() ([]sse.Event, error) {
if session != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

@tamirms under which scenarios would session be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all horizon handlers should have a non nil session. This check is only included because some of the handlers in services/horizon/internal/stream_handler_test.go do not include a session in the request context

@tamirms tamirms changed the base branch from release-horizon-v1.1.0 to master March 6, 2020 17:04
@tamirms tamirms merged commit e2fa4c7 into stellar:master Mar 6, 2020
@tamirms tamirms deleted the fix-account-comparison branch March 6, 2020 17:08
@stellar stellar deleted a comment from stellar-jenkins Mar 6, 2020
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.

Inconsistent ledger view in /accounts/{id} when streaming
3 participants