diff --git a/conn/node.go b/conn/node.go index 65f5ca18032..1a616412f81 100644 --- a/conn/node.go +++ b/conn/node.go @@ -31,6 +31,7 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" "go.etcd.io/etcd/raft" @@ -644,7 +645,7 @@ func (n *Node) WaitLinearizableRead(ctx context.Context) error { } // RunReadIndexLoop runs the RAFT index in a loop. -func (n *Node) RunReadIndexLoop(closer *y.Closer, readStateCh <-chan raft.ReadState) { +func (n *Node) RunReadIndexLoop(closer *z.Closer, readStateCh <-chan raft.ReadState) { defer closer.Done() readIndex := func(activeRctx []byte) (uint64, error) { // Read Request can get rejected then we would wait indefinitely on the channel diff --git a/conn/pool.go b/conn/pool.go index 8252db47499..dbc7a79ccf2 100644 --- a/conn/pool.go +++ b/conn/pool.go @@ -21,10 +21,10 @@ import ( "sync" "time" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2/protos/api" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" "go.opencensus.io/plugin/ocgrpc" @@ -50,7 +50,7 @@ type Pool struct { lastEcho time.Time Addr string - closer *y.Closer + closer *z.Closer healthInfo pb.HealthInfo } @@ -175,7 +175,7 @@ func newPool(addr string) (*Pool, error) { if err != nil { return nil, err } - pl := &Pool{conn: conn, Addr: addr, lastEcho: time.Now(), closer: y.NewCloser(1)} + pl := &Pool{conn: conn, Addr: addr, lastEcho: time.Now(), closer: z.NewCloser(1)} go pl.MonitorHealth() return pl, nil } diff --git a/dgraph/cmd/alpha/run.go b/dgraph/cmd/alpha/run.go index 34645db432b..3e054f2217e 100644 --- a/dgraph/cmd/alpha/run.go +++ b/dgraph/cmd/alpha/run.go @@ -33,7 +33,6 @@ import ( "syscall" "time" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2/protos/api" "github.com/dgraph-io/dgraph/edgraph" "github.com/dgraph-io/dgraph/ee/backup" @@ -43,6 +42,7 @@ import ( "github.com/dgraph-io/dgraph/tok" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" @@ -699,7 +699,7 @@ func run() { }() // Setup external communication. - aclCloser := y.NewCloser(1) + aclCloser := z.NewCloser(1) go func() { worker.StartRaftNodes(worker.State.WALstore, bindall) // initialization of the admin account can only be done after raft nodes are running diff --git a/dgraph/cmd/bulk/reduce.go b/dgraph/cmd/bulk/reduce.go index a012c885c83..48e4b57f144 100644 --- a/dgraph/cmd/bulk/reduce.go +++ b/dgraph/cmd/bulk/reduce.go @@ -39,6 +39,7 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/gogo/protobuf/proto" ) @@ -162,7 +163,7 @@ func newMapIterator(filename string) *mapIterator { } func (r *reducer) encodeAndWrite( - writer *badger.StreamWriter, entryCh chan []*pb.MapEntry, closer *y.Closer) { + writer *badger.StreamWriter, entryCh chan []*pb.MapEntry, closer *z.Closer) { defer closer.Done() var listSize int @@ -229,7 +230,7 @@ func (r *reducer) encodeAndWrite( func (r *reducer) reduce(mapItrs []*mapIterator, ci *countIndexer) { entryCh := make(chan []*pb.MapEntry, 100) - closer := y.NewCloser(1) + closer := z.NewCloser(1) defer closer.SignalAndWait() var ph postingHeap diff --git a/dgraph/cmd/zero/license.go b/dgraph/cmd/zero/license.go index a591df9e078..77f4d226fb1 100644 --- a/dgraph/cmd/zero/license.go +++ b/dgraph/cmd/zero/license.go @@ -21,7 +21,7 @@ package zero import ( "net/http" - "github.com/dgraph-io/badger/v2/y" + "github.com/dgraph-io/ristretto/z" ) // dummy function as enterprise features are not available in oss binary. @@ -30,7 +30,7 @@ func (n *node) proposeTrialLicense() error { } // periodically checks the validity of the enterprise license and updates the membership state. -func (n *node) updateEnterpriseState(closer *y.Closer) { +func (n *node) updateEnterpriseState(closer *z.Closer) { closer.Done() } diff --git a/dgraph/cmd/zero/license_ee.go b/dgraph/cmd/zero/license_ee.go index ab7633b9f77..0e03e4d909f 100644 --- a/dgraph/cmd/zero/license_ee.go +++ b/dgraph/cmd/zero/license_ee.go @@ -19,9 +19,9 @@ import ( "net/http" "time" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" humanize "github.com/dustin/go-humanize" "github.com/gogo/protobuf/proto" "github.com/golang/glog" @@ -61,7 +61,7 @@ func (s *Server) expireLicense() { // periodically checks the validity of the enterprise license and // 1. Sets license.Enabled to false in membership state if license has expired. // 2. Prints out warning once every day a week before the license is set to expire. -func (n *node) updateEnterpriseState(closer *y.Closer) { +func (n *node) updateEnterpriseState(closer *z.Closer) { defer closer.Done() interval := 5 * time.Second diff --git a/dgraph/cmd/zero/raft.go b/dgraph/cmd/zero/raft.go index 6f0ab35eb08..b313926d4ce 100644 --- a/dgraph/cmd/zero/raft.go +++ b/dgraph/cmd/zero/raft.go @@ -27,10 +27,11 @@ import ( otrace "go.opencensus.io/trace" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + farm "github.com/dgryski/go-farm" "github.com/golang/glog" "github.com/google/uuid" @@ -44,7 +45,7 @@ type node struct { *conn.Node server *Server ctx context.Context - closer *y.Closer // to stop Run. + closer *z.Closer // to stop Run. // The last timestamp when this Zero was able to reach quorum. mu sync.RWMutex @@ -529,7 +530,7 @@ func (n *node) initAndStartNode() error { return nil } -func (n *node) updateZeroMembershipPeriodically(closer *y.Closer) { +func (n *node) updateZeroMembershipPeriodically(closer *z.Closer) { defer closer.Done() ticker := time.NewTicker(10 * time.Second) defer ticker.Stop() @@ -546,7 +547,7 @@ func (n *node) updateZeroMembershipPeriodically(closer *y.Closer) { var startOption = otrace.WithSampler(otrace.ProbabilitySampler(0.01)) -func (n *node) checkQuorum(closer *y.Closer) { +func (n *node) checkQuorum(closer *z.Closer) { defer closer.Done() ticker := time.NewTicker(time.Second) defer ticker.Stop() @@ -584,7 +585,7 @@ func (n *node) checkQuorum(closer *y.Closer) { } } -func (n *node) snapshotPeriodically(closer *y.Closer) { +func (n *node) snapshotPeriodically(closer *z.Closer) { defer closer.Done() ticker := time.NewTicker(10 * time.Second) defer ticker.Stop() @@ -625,7 +626,7 @@ func (n *node) Run() { // snapshot can cause select loop to block while deleting entries, so run // it in goroutine readStateCh := make(chan raft.ReadState, 100) - closer := y.NewCloser(5) + closer := z.NewCloser(5) defer func() { closer.SignalAndWait() n.closer.Done() diff --git a/dgraph/cmd/zero/run.go b/dgraph/cmd/zero/run.go index 763aec33ce0..c887e96a221 100644 --- a/dgraph/cmd/zero/run.go +++ b/dgraph/cmd/zero/run.go @@ -35,11 +35,12 @@ import ( "github.com/dgraph-io/badger/v2" bopt "github.com/dgraph-io/badger/v2/options" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + "github.com/golang/glog" "github.com/spf13/cobra" ) @@ -146,7 +147,7 @@ func (st *state) serveGRPC(l net.Listener, store *raftwal.DiskStorage) { m.Cfg.DisableProposalForwarding = true st.rs = conn.NewRaftServer(m) - st.node = &node{Node: m, ctx: context.Background(), closer: y.NewCloser(1)} + st.node = &node{Node: m, ctx: context.Background(), closer: z.NewCloser(1)} st.zero = &Server{NumReplicas: opts.numReplicas, Node: st.node} st.zero.Init() st.node.server = st.zero @@ -282,7 +283,7 @@ func run() { x.Checkf(err, "Error while opening WAL store") defer kv.Close() - gcCloser := y.NewCloser(1) // closer for vLogGC + gcCloser := z.NewCloser(1) // closer for vLogGC go x.RunVlogGC(kv, gcCloser) defer gcCloser.SignalAndWait() diff --git a/dgraph/cmd/zero/zero.go b/dgraph/cmd/zero/zero.go index 2c8b69f12fe..91e0f4294e3 100644 --- a/dgraph/cmd/zero/zero.go +++ b/dgraph/cmd/zero/zero.go @@ -26,11 +26,12 @@ import ( otrace "go.opencensus.io/trace" "golang.org/x/net/context" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2/protos/api" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + "github.com/gogo/protobuf/proto" "github.com/golang/glog" "github.com/pkg/errors" @@ -65,7 +66,7 @@ type Server struct { // groupMap map[uint32]*Group nextGroup uint32 leaderChangeCh chan struct{} - closer *y.Closer // Used to tell stream to close. + closer *z.Closer // Used to tell stream to close. connectLock sync.Mutex // Used to serialize connect requests from servers. moveOngoing chan struct{} @@ -88,7 +89,7 @@ func (s *Server) Init() { s.nextTxnTs = 1 s.nextGroup = 1 s.leaderChangeCh = make(chan struct{}, 1) - s.closer = y.NewCloser(2) // grpc and http + s.closer = z.NewCloser(2) // grpc and http s.blockCommitsOn = new(sync.Map) s.moveOngoing = make(chan struct{}, 1) diff --git a/edgraph/access.go b/edgraph/access.go index 57ac1285597..098941621e3 100644 --- a/edgraph/access.go +++ b/edgraph/access.go @@ -21,10 +21,11 @@ package edgraph import ( "context" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2/protos/api" "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + "github.com/golang/glog" ) @@ -46,7 +47,7 @@ func ResetAcl() { } // ResetAcls is an empty method since ACL is only supported in the enterprise version. -func RefreshAcls(closer *y.Closer) { +func RefreshAcls(closer *z.Closer) { // do nothing <-closer.HasBeenClosed() closer.Done() diff --git a/edgraph/access_ee.go b/edgraph/access_ee.go index e907530dbe3..2841c329f26 100644 --- a/edgraph/access_ee.go +++ b/edgraph/access_ee.go @@ -21,14 +21,14 @@ import ( "github.com/pkg/errors" - "github.com/dgraph-io/badger/v2/y" - "github.com/dgraph-io/dgo/v2/protos/api" "github.com/dgraph-io/dgraph/ee/acl" "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + jwt "github.com/dgrijalva/jwt-go" "github.com/golang/glog" otrace "go.opencensus.io/trace" @@ -296,7 +296,7 @@ func authorizeUser(ctx context.Context, userid string, password string) ( } // RefreshAcls queries for the ACL triples and refreshes the ACLs accordingly. -func RefreshAcls(closer *y.Closer) { +func RefreshAcls(closer *z.Closer) { defer closer.Done() if len(worker.Config.HmacSecret) == 0 { // the acl feature is not turned on diff --git a/go.mod b/go.mod index 05e80935b21..52127c3d3d3 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd github.com/dgraph-io/badger/v2 v2.2007.2-0.20200827131741-d5a25b83fbf4 github.com/dgraph-io/dgo/v2 v2.1.1-0.20191127085444-c7a02678e8a6 - github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de + github.com/dgraph-io/ristretto v0.0.4-0.20200904131139-4dec2770af66 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 github.com/dgryski/go-groupvarint v0.0.0-20190318181831-5ce5df8ca4e1 diff --git a/go.sum b/go.sum index 2bda9d2720a..e086768e12f 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,7 @@ contrib.go.opencensus.io/exporter/prometheus v0.1.0 h1:SByaIoWwNgMdPSgl5sMqM2KDE contrib.go.opencensus.io/exporter/prometheus v0.1.0/go.mod h1:cGFniUXGZlKRjzOyuZJ6mgB+PgBcCIa79kEKR8YCW+A= github.com/99designs/gqlgen v0.10.1 h1:1BgB6XKGTHq7uH4G1/PYyKe2Kz7/vw3AlvMZlD3TEEY= github.com/99designs/gqlgen v0.10.1/go.mod h1:IviubpnyI4gbBcj8IcxSSc/Q/+af5riwCmJmwF0uaPE= +github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.2 h1:2L2f5t3kKnCLxnClDD/PrDfExFFa1wjESgxHG/B1ibo= @@ -62,12 +63,20 @@ github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkE github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/badger v1.6.1 h1:w9pSFNSdq/JPM1N12Fz/F/bzo993Is1W+Q7HjPzi7yg= +github.com/dgraph-io/badger v1.6.1/go.mod h1:FRmFw3uxvcpa8zG3Rxs0th+hCLIuaQg8HlNV5bjgnuU= github.com/dgraph-io/badger/v2 v2.2007.2-0.20200827131741-d5a25b83fbf4 h1:DUDFTVgqZysKplH39/ya0aI4+zGm91L9QttXgITT2YE= github.com/dgraph-io/badger/v2 v2.2007.2-0.20200827131741-d5a25b83fbf4/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= +github.com/dgraph-io/dgo v1.0.0 h1:DRuI66G+j0XWDOXly4v5PSk2dGkbIopAZIirRjq7lzI= github.com/dgraph-io/dgo/v2 v2.1.1-0.20191127085444-c7a02678e8a6 h1:5leDFqGys055YO3TbghBhk/QdRPEwyLPdgsSJfiR20I= github.com/dgraph-io/dgo/v2 v2.1.1-0.20191127085444-c7a02678e8a6/go.mod h1:LJCkLxm5fUMcU+yb8gHFjHt7ChgNuz3YnQQ6MQkmscI= +github.com/dgraph-io/dgo/v200 v200.0.0-20200825025457-a38d5eaacbf8 h1:twtbiz+2PsuJEZWP+WGYdJEtD/NW1d7T5m3EN9JSBXI= +github.com/dgraph-io/dgo/v200 v200.0.0-20200825025457-a38d5eaacbf8/go.mod h1:Co+FwJrnndSrPORO8Gdn20dR7FPTfmXr0W/su0Ve/Ig= +github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de h1:t0UHb5vdojIDUqktM6+xJAfScFBsVpXZmqC9dsgJmeA= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.0.4-0.20200904131139-4dec2770af66 h1:ectpJv2tGhTudyk0JhqE/53o/ObH30u5yt/yThsAn3I= +github.com/dgraph-io/ristretto v0.0.4-0.20200904131139-4dec2770af66/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -150,6 +159,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.0.0/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= diff --git a/posting/lists.go b/posting/lists.go index fbdd25c572a..879acdd618b 100644 --- a/posting/lists.go +++ b/posting/lists.go @@ -31,8 +31,9 @@ import ( ostats "go.opencensus.io/stats" "github.com/dgraph-io/badger/v2" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2/protos/api" + "github.com/dgraph-io/ristretto/z" + "github.com/golang/glog" "github.com/dgraph-io/dgraph/protos/pb" @@ -89,7 +90,7 @@ func getMemUsage() int { return rss * os.Getpagesize() } -func updateMemoryMetrics(lc *y.Closer) { +func updateMemoryMetrics(lc *z.Closer) { defer lc.Done() ticker := time.NewTicker(time.Minute) defer ticker.Stop() @@ -129,13 +130,13 @@ func updateMemoryMetrics(lc *y.Closer) { var ( pstore *badger.DB - closer *y.Closer + closer *z.Closer ) // Init initializes the posting lists package, the in memory and dirty list hash. func Init(ps *badger.DB) { pstore = ps - closer = y.NewCloser(1) + closer = z.NewCloser(1) go updateMemoryMetrics(closer) } diff --git a/raftwal/storage.go b/raftwal/storage.go index d6943695c92..d362cd3ec35 100644 --- a/raftwal/storage.go +++ b/raftwal/storage.go @@ -23,9 +23,9 @@ import ( "sync" "github.com/dgraph-io/badger/v2" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/gogo/protobuf/proto" "github.com/golang/glog" "github.com/pkg/errors" @@ -42,7 +42,7 @@ type DiskStorage struct { elog trace.EventLog cache *sync.Map - Closer *y.Closer + Closer *z.Closer indexRangeChan chan indexRange } @@ -57,7 +57,7 @@ func Init(db *badger.DB, id uint64, gid uint32) *DiskStorage { id: id, gid: gid, cache: new(sync.Map), - Closer: y.NewCloser(1), + Closer: z.NewCloser(1), indexRangeChan: make(chan indexRange, 16), } if prev, err := RaftId(db); err != nil || prev != id { diff --git a/worker/draft.go b/worker/draft.go index 66769ae67b2..2327355222d 100644 --- a/worker/draft.go +++ b/worker/draft.go @@ -35,7 +35,6 @@ import ( "github.com/dgraph-io/badger/v2" bpb "github.com/dgraph-io/badger/v2/pb" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/dgraph/cmd/zero" "github.com/dgraph-io/dgraph/posting" @@ -44,6 +43,8 @@ import ( "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" + "github.com/pkg/errors" "github.com/golang/glog" @@ -59,7 +60,7 @@ type node struct { rollupCh chan uint64 // Channel to run posting list rollups. ctx context.Context gid uint32 - closer *y.Closer + closer *z.Closer streaming int32 // Used to avoid calculating snapshot @@ -92,7 +93,7 @@ func newNode(store *raftwal.DiskStorage, gid uint32, id uint64, myAddr string) * applyCh: make(chan []*pb.Proposal, 1000), rollupCh: make(chan uint64, 3), elog: trace.NewEventLog("Dgraph", "ApplyCh"), - closer: y.NewCloser(3), // Matches CLOSER:1 + closer: z.NewCloser(3), // Matches CLOSER:1 } return n } diff --git a/worker/groups.go b/worker/groups.go index a2220ae3f94..2b28b36c038 100644 --- a/worker/groups.go +++ b/worker/groups.go @@ -28,7 +28,6 @@ import ( "github.com/dgraph-io/badger/v2" badgerpb "github.com/dgraph-io/badger/v2/pb" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2/protos/api" "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/ee/enc" @@ -36,6 +35,7 @@ import ( "github.com/dgraph-io/dgraph/raftwal" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/golang/protobuf/proto" "github.com/pkg/errors" @@ -52,7 +52,7 @@ type groupi struct { tablets map[string]*pb.Tablet triggerCh chan struct{} // Used to trigger membership sync blockDeletes *sync.Mutex // Ensure that deletion won't happen when move is going on. - closer *y.Closer + closer *z.Closer // Group checksum is used to determine if the tablets served by the groups have changed from // the membership information that the Alpha has. If so, Alpha cannot service a read. @@ -155,7 +155,7 @@ func StartRaftNodes(walStore *badger.DB, bindall bool) { x.UpdateHealthStatus(true) glog.Infof("Server is ready") - gr.closer = y.NewCloser(3) // Match CLOSER:1 in this file. + gr.closer = z.NewCloser(3) // Match CLOSER:1 in this file. go gr.sendMembershipUpdates() go gr.receiveMembershipUpdates() go gr.processOracleDeltaStream() diff --git a/worker/mutation.go b/worker/mutation.go index 28106b89f72..a6decdcc242 100644 --- a/worker/mutation.go +++ b/worker/mutation.go @@ -24,7 +24,6 @@ import ( "github.com/dgraph-io/badger/v2" "github.com/dgraph-io/dgo/v2" "github.com/dgraph-io/dgo/v2/protos/api" - "github.com/dgraph-io/dgraph/conn" "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/protos/pb" diff --git a/worker/server_state.go b/worker/server_state.go index c0edacb79b8..792c46546ef 100644 --- a/worker/server_state.go +++ b/worker/server_state.go @@ -23,10 +23,10 @@ import ( "github.com/dgraph-io/badger/v2" "github.com/dgraph-io/badger/v2/options" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgraph/ee/enc" "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/x" + "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "golang.org/x/net/context" ) @@ -38,7 +38,7 @@ type ServerState struct { Pstore *badger.DB WALstore *badger.DB - gcCloser *y.Closer // closer for valueLogGC + gcCloser *z.Closer // closer for valueLogGC needTs chan tsReq } @@ -184,7 +184,7 @@ func (s *ServerState) initStorage() { opt.EncryptionKey = nil } - s.gcCloser = y.NewCloser(2) + s.gcCloser = z.NewCloser(2) go x.RunVlogGC(s.Pstore, s.gcCloser) go x.RunVlogGC(s.WALstore, s.gcCloser) } diff --git a/x/x.go b/x/x.go index b88d7c1fc3a..9d21220acbf 100644 --- a/x/x.go +++ b/x/x.go @@ -36,9 +36,9 @@ import ( "time" "github.com/dgraph-io/badger/v2" - "github.com/dgraph-io/badger/v2/y" "github.com/dgraph-io/dgo/v2" "github.com/dgraph-io/dgo/v2/protos/api" + "github.com/dgraph-io/ristretto/z" "github.com/golang/glog" "github.com/pkg/errors" @@ -820,7 +820,7 @@ func IsGuardian(groups []string) bool { // RunVlogGC runs value log gc on store. It runs GC unconditionally after every 10 minutes. // Additionally it also runs GC if vLogSize has grown more than 1 GB in last minute. -func RunVlogGC(store *badger.DB, closer *y.Closer) { +func RunVlogGC(store *badger.DB, closer *z.Closer) { defer closer.Done() // Get initial size on start. _, lastVlogSize := store.Size()