diff --git a/dgraph/cmd/counter/.gitignore b/dgraph/cmd/increment/.gitignore similarity index 100% rename from dgraph/cmd/counter/.gitignore rename to dgraph/cmd/increment/.gitignore diff --git a/dgraph/cmd/counter/increment.go b/dgraph/cmd/increment/increment.go similarity index 98% rename from dgraph/cmd/counter/increment.go rename to dgraph/cmd/increment/increment.go index 8bddcf69621..97ca43ce035 100644 --- a/dgraph/cmd/counter/increment.go +++ b/dgraph/cmd/increment/increment.go @@ -14,10 +14,10 @@ * limitations under the License. */ -// Package counter builds a tool that retrieves a value for UID=0x01, and increments +// Package increment builds a tool that retrieves a value for UID=0x01, and increments // it by 1. If successful, it prints out the incremented value. It assumes that it has // access to UID=0x01, and that `val` predicate is of type int. -package counter +package increment import ( "context" diff --git a/dgraph/cmd/counter/increment_test.go b/dgraph/cmd/increment/increment_test.go similarity index 99% rename from dgraph/cmd/counter/increment_test.go rename to dgraph/cmd/increment/increment_test.go index f79451e1b97..afc3a88de74 100644 --- a/dgraph/cmd/counter/increment_test.go +++ b/dgraph/cmd/increment/increment_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package counter +package increment import ( "context" diff --git a/dgraph/cmd/root.go b/dgraph/cmd/root.go index e6a89077e16..80892d095c9 100644 --- a/dgraph/cmd/root.go +++ b/dgraph/cmd/root.go @@ -25,9 +25,9 @@ import ( "github.com/dgraph-io/dgraph/dgraph/cmd/bulk" "github.com/dgraph-io/dgraph/dgraph/cmd/cert" "github.com/dgraph-io/dgraph/dgraph/cmd/conv" - "github.com/dgraph-io/dgraph/dgraph/cmd/counter" "github.com/dgraph-io/dgraph/dgraph/cmd/debug" "github.com/dgraph-io/dgraph/dgraph/cmd/debuginfo" + "github.com/dgraph-io/dgraph/dgraph/cmd/increment" "github.com/dgraph-io/dgraph/dgraph/cmd/live" "github.com/dgraph-io/dgraph/dgraph/cmd/migrate" "github.com/dgraph-io/dgraph/dgraph/cmd/version" @@ -75,7 +75,7 @@ var rootConf = viper.New() // subcommands initially contains all default sub-commands. var subcommands = []*x.SubCommand{ &bulk.Bulk, &cert.Cert, &conv.Conv, &live.Live, &alpha.Alpha, &zero.Zero, &version.Version, - &debug.Debug, &counter.Increment, &migrate.Migrate, &debuginfo.DebugInfo, &upgrade.Upgrade, + &debug.Debug, &increment.Increment, &migrate.Migrate, &debuginfo.DebugInfo, &upgrade.Upgrade, } func initCmds() { diff --git a/posting/lists.go b/posting/lists.go index a61ff264a34..212dcc06f97 100644 --- a/posting/lists.go +++ b/posting/lists.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "io/ioutil" - "math" "os" "os/exec" "runtime" @@ -181,6 +180,12 @@ func NewLocalCache(startTs uint64) *LocalCache { } } +// NoCache returns a new LocalCache instance, which won't cache anything. Useful to pass startTs +// around. +func NoCache(startTs uint64) *LocalCache { + return &LocalCache{startTs: startTs} +} + func (lc *LocalCache) getNoStore(key string) *List { lc.RLock() defer lc.RUnlock() @@ -205,8 +210,8 @@ func (lc *LocalCache) SetIfAbsent(key string, updated *List) *List { } func (lc *LocalCache) getInternal(key []byte, readFromDisk bool) (*List, error) { - if lc == nil { - return getNew(key, pstore, math.MaxUint64) + if lc.plists == nil { + return getNew(key, pstore, lc.startTs) } skey := string(key) if pl := lc.getNoStore(skey); pl != nil { diff --git a/worker/task.go b/worker/task.go index 337775a3106..157b665293c 100644 --- a/worker/task.go +++ b/worker/task.go @@ -881,6 +881,9 @@ func processTask(ctx context.Context, q *pb.Query, gid uint32) (*pb.Result, erro if q.Cache == UseTxnCache { qs.cache = posting.Oracle().CacheAt(q.ReadTs) } + if qs.cache == nil { + qs.cache = posting.NoCache(q.ReadTs) + } // For now, remove the query level cache. It is causing contention for queries with high // fan-out.