You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To prevent queries from piling up when the server is overloaded, they should be cancelled if they run too long. The ability to cancel queries is also desirable.
The PostgreSQL driver we use (github.com/lib/pq) supports these functions too: lib/pq#535. However it looks like there is some left to implement: lib/pq#768
More background: The context package added in go1.7 is used to convey request-scoped data like deadlines and cancel signals. For the http handlers in our explorer and api packages, we use WithValue extensively. For the db packages, we'll be instrumenting with WithCancel, WithDeadline, and WithTimeout, which each return a CancelFunc that is called to cancel the context and all child contexts. The interrupt signal handling should make use of this.
For our db queries, using WithTimeout is likely to be more natural than WithDeadline, which is called by WithTimeout. We should create a context for each new query, using a timeout that should be user-configurable via the dcrdata config. The context will be passed to the query function (e.g. ExecContext), which will cancel the query if the time exceeds the timeout.
The text was updated successfully, but these errors were encountered:
To prevent queries from piling up when the server is overloaded, they should be cancelled if they run too long. The ability to cancel queries is also desirable.
The
database/sql
package supports usingcontext.Context
for query cancellation and timeout (QueryContext
,QueryRowContext
,ExecContext
, etc): https://docs.google.com/document/d/1F778e7ZSNiSmbju3jsEWzShcb8lIO4kDyfKDNm4PNd8/editThe PostgreSQL driver we use (github.com/lib/pq) supports these functions too: lib/pq#535. However it looks like there is some left to implement: lib/pq#768
More background: The context package added in go1.7 is used to convey request-scoped data like deadlines and cancel signals. For the http handlers in our explorer and api packages, we use
WithValue
extensively. For the db packages, we'll be instrumenting withWithCancel
,WithDeadline
, andWithTimeout
, which each return aCancelFunc
that is called to cancel the context and all child contexts. The interrupt signal handling should make use of this.For our db queries, using
WithTimeout
is likely to be more natural thanWithDeadline
, which is called byWithTimeout
. We should create a context for each new query, using a timeout that should be user-configurable via the dcrdata config. The context will be passed to the query function (e.g.ExecContext
), which will cancel the query if the time exceeds the timeout.The text was updated successfully, but these errors were encountered: