-
Notifications
You must be signed in to change notification settings - Fork 499
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
Change ingest.ledgerbackend.LedgerBackend.GetLedger to be always blocking #3549
Comments
So, turns out we do still need a non-blocking version for serving web requests at https://github.com/stellar/go/blob/master/exp/services/captivecore/internal/api.go#L173. Or we need to change how that is handled. We could either:
|
Yeah, this is what I suggested in the first comment. So a blocking |
Thinking out loud Ok, so in We can either:
|
@paulbellamy |
We could also do something similar to |
How does that help? Unlike PrepareRange, GetLedger needs to return data back to the client, so if the client is gone there's no reason to keep the GetLedger call alive.
Yeah, agreed. But RemoteCaptiveCore need some way to differentiate "timed out because the data isn't there" (http 408 maybe?) from "timed out because the server is broken" (http 504 maybe?). Is RemoteCaptiveCore ever used to talk to "captive cores" outside the horizon process? Specifically, could RemoteCaptiveCore ever be talking to a core of a different version from the horizon instance? |
The remote captive core API does return data back to the client for PrepareRange. Also, there is a reason to keep the GetLedger call alive even if the client request ends. GetLedger calls are always non-decreasing. The client wants to keep advancing the ledger stream. Once captive core reaches desired ledger from the GetLedger call, that ledger is cached so that subsequent calls for the same ledger return instantly. |
What problem does your feature solve?
Currently
LedgerBackend
interface has twoGetLedger
methods:GetLedger
that has a different behaviour depending on how the range was prepared:UnboundedRange
it's non-blocking,BoundedRange
it is blocking.GetLedgerBlocking
that is always blocking no matter how the range was prepared (added just recently in services/horizon: Removed LedgerBackend calls inside ingest critical section #3518).After a short discussion with @tamirms we realized that maybe we don't need a non-blocking version at all.
There are several advantages of blocking
GetLedger
:GetLedger
in a non-blocking mode, caller usually callstime.Sleep
between the consecutive calls toGetLedger
. This extends time between a request of the ledger data and the response.GetLedger
requesting the latest ledger sequence in a buffer to be able to make Captive-Core to proceed. Without it, Captive-Core was stopped because it contains only a small buffer of ledger data it can return to the caller.GetLedger
was created to be non-blocking because it was using Stellar-Core DB. Right now, with Captive-Core we don't have this requirement.What would you like to see?
GetLedgerBlocking
method.GetLedger
:GetLedger(ctx context.Context, sequence uint32) (xdr.LedgerCloseMeta, error)
bool
return value and addctx
argument.ctx
is cancelled orLedgerBackend.Close()
is calledGetLedger
returns emptyxdr.LedgerCloseMeta
andcontext.Canceled
orcontext.DeadlineExceeded
.This breaking change should be released in accordance with semver.
What alternatives are there?
The text was updated successfully, but these errors were encountered: