Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

use Context's properly to stop executing when a request is canceled #728

Merged
merged 11 commits into from
Dec 5, 2017

Commits on Nov 21, 2017

  1. use context.Context's properly stop executing when a request is canceled

    - The ctx was already being passed between the different methods
      within the query pipeline, but the context was never being inspected
      to see if it had been canceled. This commit fixes that.
    - Now when an error occurs, whether that error is local or on a remote
      peer, the request is immediately canceled.
    - if the client disconnects before a response is returned (whether
      that is due to a timeout or the client canceling the request), that
      cancelation will propagate throught and abort any work.
    woodsaj committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    2319ad7 View commit details
    Browse the repository at this point in the history
  2. add per request ratelimiting of getTargetsLocal

    limit the number of getTargetsLocal threads that can be running at
    once. This ensures that if a large query that spans 1000s of series
    is executed, 1000s of goroutines wont be run at once to hit the
    caches and cassandra.
    This also ensures that a single query cant fill the cassandra
    read queue.  Mt only executes cassandra-read-concurrency requests
    at a time so requests will always need to be queued. With this new
    approach multiple render requests will share read queue and their
    read requests will be interspaced in the queue, rather then the old
    behaviour where a render request would have to complete all of its
    reads before the next render request would be processed.
    
    Overall this will lead to a more consistant performance profile
    for render requests.
    woodsaj committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    c8207b2 View commit details
    Browse the repository at this point in the history
  3. dont pass a cancelFunc to getTargetsRemote/Local

    woodsaj committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    b4c0648 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f5a5988 View commit details
    Browse the repository at this point in the history
  5. more consistant conetxt.WithCancel logic

    - the functions that spawn background work in new goroutines should
      be responsible for signalling to them that they should shutdown.
      So these functions should create a context.WithCancel and call cancel
      when the the first error is encounted.
    woodsaj committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    d763539 View commit details
    Browse the repository at this point in the history
  6. check if context is canceled before searching idx

    woodsaj committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    e87b6a1 View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2017

  1. use contexts correctly in tag methods

    woodsaj committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    e08a3ca View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2017

  1. pass errors instead of panicing in data fetch pipeline

    - Instead of calling panic and having to recover the panic later,
      just pass errors throught the data fetch (getTargets) pipeline.
      This allows us to correctly cancel requests via the request
      context.
    woodsaj committed Dec 1, 2017
    Configuration menu
    Copy the full SHA
    7d3e803 View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2017

  1. fix

    Dieterbe committed Dec 4, 2017
    Configuration menu
    Copy the full SHA
    2e98a0d View commit details
    Browse the repository at this point in the history
  2. cleanup Server.getTarget()

    * no need to wrap an if err clause around s.getSeriesFixed(), as the
      output is always correct (in particular, when it returns an error, the
      series is nil)
    * add consolidation.ConsolidateContext() wrapper so that the caller
      doesn't need to check the context prior to a call to
      consolidation.Consolidate()
    * ditto for divideContext() -> divide()
    * ditto for getSeriesFixed, except it doesn't need a wrapper, it was
      already checking the ctx.Done for most of its work (but not all)
    Dieterbe committed Dec 4, 2017
    Configuration menu
    Copy the full SHA
    04b955e View commit details
    Browse the repository at this point in the history
  3. typo

    Dieterbe committed Dec 4, 2017
    Configuration menu
    Copy the full SHA
    e8eefaf View commit details
    Browse the repository at this point in the history