Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP(20.07): Fix(increment): Fix readTs less than minTs (#6317) #6517

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package counter
package increment

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions dgraph/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 8 additions & 3 deletions posting/lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"io/ioutil"
"math"
"os"
"os/exec"
"runtime"
Expand Down Expand Up @@ -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()
Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down