Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: filter/dscache/ds.go

Issue 1695833002: dscache: Only log unusual memcache errors. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Rewrite with errors.Filter Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | filter/dscache/ds_txn_state.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/dscache/ds.go
diff --git a/filter/dscache/ds.go b/filter/dscache/ds.go
index 542ada6b111cf2335a76602acdf94e10addec238..b466d46e3c2782e17ff4ab5bf3022ba8e9904808 100644
--- a/filter/dscache/ds.go
+++ b/filter/dscache/ds.go
@@ -9,6 +9,7 @@ import (
ds "github.com/luci/gae/service/datastore"
"github.com/luci/gae/service/memcache"
+ "github.com/luci/luci-go/common/errors"
log "github.com/luci/luci-go/common/logging"
"golang.org/x/net/context"
)
@@ -44,7 +45,7 @@ func (d *dsCache) GetMulti(keys []*ds.Key, metas ds.MultiMetaGetter, cb ds.GetMu
// (so, not an issue), or because memcache is having sad times (in which
// case we'll see so in the GetMulti which immediately follows this).
}
- if err := d.mc.GetMulti(lockItems); err != nil {
+ if err := filterMCErr(d.mc.GetMulti(lockItems)); err != nil {
(log.Fields{log.ErrorKey: err}).Warningf(
d.c, "dscache: GetMulti: memcache.GetMulti")
}
@@ -139,3 +140,14 @@ func (d *dsCache) RunInTransaction(f func(context.Context) error, opts *ds.Trans
}
return err
}
+
+// filterMCErr filters expected memcache failure errors from the supplied err.
+// If err is composed exclusively of expected failure errors, filterMCErr will
+// return nil
+//
+// The following error types are filtered:
+// - ErrCacheMiss: memcache is permitted to evict cache items at its
+// discretion.
+func filterMCErr(err error) error {
iannucci 2016/02/13 00:16:44 inline this sucka!
+ return errors.Filter(err, memcache.ErrCacheMiss)
+}
« no previous file with comments | « no previous file | filter/dscache/ds_txn_state.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698