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

Segfetcher: Make NextQuery dependent on segments #3208

Merged
merged 8 commits into from
Oct 2, 2019

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Oct 1, 2019

With this PR, the next query is dependent on the verified segments.
The next query interval is at least minQueryInterval and at most
the configured query interval.

However, if only segments are found where the time until segment
expiration minus the expirationLeadTime (2 minutes) are found that are
less than the configured query interval, then that is chosen.

I.e. the query interval is:

maxExpirationDiff = max(seg.Exp().Add(-expirationLeadTime).Sub(now))
min(max(minQueryInterval, maxExpirationDiff), QueryInterval)

fixes #2979

Also, revert band-aid fix introduced by #3089

This change is Reviewable

@oncilla oncilla force-pushed the pub-smart-next-query branch from 72c4063 to 28eacf7 Compare October 1, 2019 14:45
@oncilla oncilla changed the title establish baseline Segfetcher: Make NextQuery dependent on segments Oct 1, 2019
@oncilla oncilla marked this pull request as ready for review October 1, 2019 14:51
@oncilla oncilla requested a review from scrye October 1, 2019 14:56
@oncilla oncilla added the bug Something isn't working label Oct 1, 2019
@scrye
Copy link
Contributor

scrye commented Oct 1, 2019


go/lib/infra/modules/segfetcher/fetcher.go, line 198 at r1 (raw file):

// nextQuery decides the next time a query should be issued based on the
// received segments.
func (f *Fetcher) nextQuery(segs []*seghandler.SegWithHP) time.Time {

Maybe simplify this a bit:

lastExpiration := getLastExpiration(segs)
lastExpiration -= expirationLeadTime
relativeNextQuery := findNearestInInterval(lastExpiration, minQueryInterval, f.QueryInterval)
return time.Now() + relativeNextQuery

Better names probably exist.

With this PR, the next query is dependent on the verified segments.
The next query interval is at least minQueryInterval and at most
the configured query interval.

However, if only segments are found where the time until segment
expiration minus the `expirationLeadTime` (2 minutes) are found that are
less than the configured query interval, then that is chosen.

I.e. the query interval is:
````
maxExpirationDiff = max(seg.Exp().Add(-expirationLeadTime).Sub(now))
min(max(minQueryInterval, maxExpirationDiff), QueryInterval)
````

fixes scionproto#2979
@oncilla oncilla force-pushed the pub-smart-next-query branch from 36e78a0 to 767c82e Compare October 2, 2019 07:00
Copy link
Contributor Author

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 1 unresolved discussion (waiting on @scrye)


go/lib/infra/modules/segfetcher/fetcher.go, line 198 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

Maybe simplify this a bit:

lastExpiration := getLastExpiration(segs)
lastExpiration -= expirationLeadTime
relativeNextQuery := findNearestInInterval(lastExpiration, minQueryInterval, f.QueryInterval)
return time.Now() + relativeNextQuery

Better names probably exist.

Done.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 5 of 5 files at r1, 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@oncilla oncilla merged commit 9f6cf41 into scionproto:master Oct 2, 2019
@oncilla oncilla deleted the pub-smart-next-query branch October 2, 2019 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smarter NextQuery value for soon to expire segments
2 participants