From ca1c4431563daa070d27ff262b57e6705c3045f1 Mon Sep 17 00:00:00 2001 From: Manish R Jain <manishrjain@gmail.com> Date: Tue, 1 Mar 2016 12:24:42 +1100 Subject: [PATCH] Fixes after testing uid assignment and query execution over multiple workers --- Dockerfile | 4 ++-- query/query.go | 15 +++++++-------- worker/task.go | 6 ++++-- worker/worker.go | 1 + 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index d963c15c..51c74a4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Dockerfile for DGraph -FROM golang:1.4.3 +FROM golang:1.5.3 MAINTAINER Manish Jain <manishrjain@gmail.com> # Get the necessary packages. @@ -21,7 +21,7 @@ ENV LD_LIBRARY_PATH "/usr/local/lib" # Install DGraph and update dependencies to right versions. RUN go get -v github.com/robfig/glock && \ go get -v github.com/dgraph-io/dgraph/... && \ - glock sync github.com/dgraph-io/dgraph && echo "v0.1.3" + glock sync github.com/dgraph-io/dgraph && echo "v0.2.0" # Run some tests, don't build an image if we're failing tests. RUN go test github.com/dgraph-io/dgraph/... diff --git a/query/query.go b/query/query.go index e564c873..0c5c3d92 100644 --- a/query/query.go +++ b/query/query.go @@ -27,7 +27,6 @@ import ( "github.com/dgraph-io/dgraph/gql" "github.com/dgraph-io/dgraph/posting" "github.com/dgraph-io/dgraph/task" - "github.com/dgraph-io/dgraph/uid" "github.com/dgraph-io/dgraph/worker" "github.com/dgraph-io/dgraph/x" "github.com/google/flatbuffers/go" @@ -275,15 +274,15 @@ func newGraph(euid uint64, exid string) (*SubGraph, error) { // This would set the Result field in SubGraph, // and populate the children for attributes. if len(exid) > 0 { - // instanceIdx = 0, numInstances = 1 by default - u, err := uid.GetOrAssign(exid, 0, 1) - if err != nil { - x.Err(glog, err).WithField("xid", exid).Error( - "While GetOrAssign uid from external id") + xidToUid := make(map[string]uint64) + xidToUid[exid] = 0 + if err := worker.GetOrAssignUidsOverNetwork(&xidToUid); err != nil { + glog.WithError(err).Error("While getting uids over network") return nil, err } - glog.WithField("xid", exid).WithField("_uid_", u).Debug("GetOrAssign") - euid = u + + euid = xidToUid[exid] + glog.WithField("xid", exid).WithField("uid", euid).Debug("GetOrAssign") } if euid == 0 { diff --git a/worker/task.go b/worker/task.go index 5ce45ff3..bdcdcf4b 100644 --- a/worker/task.go +++ b/worker/task.go @@ -16,6 +16,8 @@ func ProcessTaskOverNetwork(qu []byte) (result []byte, rerr error) { attr := string(q.Attr()) idx := farm.Fingerprint64([]byte(attr)) % numInstances + glog.WithField("idx", idx).WithField("attr", attr). + WithField("numInstances", numInstances).Debug("ProcessTaskOverNetwork") var runHere bool if attr == "_xid_" || attr == "_uid_" { @@ -39,8 +41,8 @@ func ProcessTaskOverNetwork(qu []byte) (result []byte, rerr error) { if err := pool.Call("Worker.ServeTask", query, reply); err != nil { glog.WithField("call", "Worker.ServeTask").Fatal(err) } - glog.WithField("reply", string(reply.Data)).WithField("addr", addr). - Info("Got reply from server") + glog.WithField("reply_len", len(reply.Data)).WithField("addr", addr). + Debug("Got reply from server") return reply.Data, nil } diff --git a/worker/worker.go b/worker/worker.go index 3fd932e8..6a287101 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -126,6 +126,7 @@ func (w *Worker) ServeTask(query *conn.Query, reply *conn.Reply) (rerr error) { q := new(task.Query) q.Init(query.Data, uo) attr := string(q.Attr()) + glog.WithField("attr", attr).Debug("ServeTask") if farm.Fingerprint64([]byte(attr))%numInstances == instanceIdx { reply.Data, rerr = processTask(query.Data) -- GitLab