Commit 23c16ba8 authored by ale's avatar ale
Browse files

Set shorter RPC timeout for auxdb calls

This is auxiliary data, so it's best to time out early if the backends
are unreachable and still have time to return the User response.
parent 88f74ec3
Pipeline #29264 passed with stages
in 3 minutes and 45 seconds
......@@ -6,6 +6,7 @@ import (
"log"
"strings"
"sync"
"time"
as "git.autistici.org/ai3/accountserver"
"git.autistici.org/ai3/go-common/clientutil"
......@@ -18,6 +19,10 @@ const auxDbWebappDataType = "cms_info"
// Data type of disk usage resources in aux-db.
const auxDbDiskUsageDataType = "disk_usage"
// Timeout to use for auxdb RPCs. It's fast so we can time out early
// if the backends are unreachable.
var auxdbTimeout = 3 * time.Second
// AuxWebappBackend looks up website information (cms_info data type) in
// the aux-db service.
//
......@@ -148,7 +153,10 @@ func lookupsForResources(resources []*as.Resource) (lookups []*lookupEntry) {
return
}
func (tx *wdbTX) lookup(ctx context.Context, lookups []*lookupEntry) {
func (tx *wdbTX) lookup(outerCtx context.Context, lookups []*lookupEntry) {
ctx, cancel := context.WithTimeout(outerCtx, auxdbTimeout)
defer cancel()
// Group the keys by shard, and build a reverse index of keys
// -> callbacks, that we'll use to process the results.
keysByShard := make(map[string][]auxpb.Key)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment