diff --git a/executor.go b/executor.go index 7e046c11c..a2b6b8968 100644 --- a/executor.go +++ b/executor.go @@ -143,7 +143,6 @@ func (e *executor) Close() error { // Execute executes a PQL query. func (e *executor) Execute(ctx context.Context, index string, q *pql.Query, shards []uint64, opt *execOptions) (QueryResponse, error) { - span, ctx := tracing.StartSpanFromContext(ctx, "Executor.Execute") span.LogKV("pql", q.String()) defer span.Finish() @@ -1516,7 +1515,18 @@ func executeDistinctShardSet(ctx context.Context, qcx *Qcx, idx *Index, fieldNam fragData, _, err := tx.ContainerIterator(index, fieldName, "standard", shard, 0) switch errors.Cause(err) { case ViewNotFound, FragmentNotFound: - return nil, nil + // It may seem reasonable to return `nil` here in the case where the + // fragment for this shard does not exist. The problem with doing that + // is that if this operation is being performed on a remote node, then + // this result is going to get serialized as a QueryResponse and sent + // back to the original, non-remote node. When this happens, the + // encodeRow/decodeRow logic replaces `nil` with an empty Row. An empty + // Row will cause problems during the union step of the reduce phase if + // it is the "left" side of the union, because then the resulting Row + // after the union will have blank Index and Field values. Here, we + // ensure that we send a non-nil Row with valid Index and Field values + // so that the union step doesn't cause problems. + return &Row{Index: index, Field: fieldName}, nil case nil: default: return nil, errors.Wrap(err, "getting fragment data") diff --git a/lattice b/lattice index 36f453c1e..28c2313ec 160000 --- a/lattice +++ b/lattice @@ -1 +1 @@ -Subproject commit 36f453c1ea3bf86c546a8ad4a88f2a926724d683 +Subproject commit 28c2313ecfcd7e083d42d4e409483e968b4c421b diff --git a/server/server.go b/server/server.go index 291c986e1..530e4102a 100644 --- a/server/server.go +++ b/server/server.go @@ -24,6 +24,7 @@ import ( "context" "crypto/tls" "io" + "io/ioutil" "log" "math/rand" "net" @@ -31,6 +32,7 @@ import ( "os/signal" "runtime" "strconv" + "strings" "sync" "syscall" "time" @@ -152,6 +154,20 @@ func (m *Command) Start() (err error) { return errors.Wrap(err, "setting up server") } + if runtime.GOOS == "linux" { + result, err := ioutil.ReadFile("/proc/sys/vm/max_map_count") + if err != nil { + m.logger.Printf("Tried unsuccessfully to check system mmap limit: %v", err) + } else { + sysMmapLimit, err := strconv.ParseUint(strings.TrimSuffix(string(result), "\n"), 10, 64) + if err != nil { + m.logger.Printf("Tried unsuccessfully to check system mmap limit: %v", err) + } else if m.Config.MaxMapCount > sysMmapLimit { + m.logger.Printf("WARNING: Config max map limit (%v) is greater than current system limits (%v)", m.Config.MaxMapCount, sysMmapLimit) + } + } + } + // Set up networking (i.e. gossip) err = m.setupNetworking() if err != nil {