From bfd837eec7746aeeb31c82cc97b51d915b1b8c91 Mon Sep 17 00:00:00 2001 From: Noah Treuhaft Date: Wed, 19 May 2021 19:40:48 -0700 Subject: [PATCH] service/search: ignore request span if pool has no span --- service/search/search.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/service/search/search.go b/service/search/search.go index eccb20519c..de2807d8ed 100644 --- a/service/search/search.go +++ b/service/search/search.go @@ -98,7 +98,7 @@ func (s *SearchOp) Run(ctx context.Context, adaptor proc.DataAdaptor, pool *lake scanOrder = "desc" } var scanRange *ast.Range - if s.query.Span.Dur != 0 { + if s.query.Span.Dur != 0 && poolHasSpan(ctx, pool) { scanRange = &ast.Range{ Kind: "Range", Lower: &zed.Primitive{ @@ -132,6 +132,18 @@ func (s *SearchOp) Run(ctx context.Context, adaptor proc.DataAdaptor, pool *lake return driver.RunWithLakeAndStats(ctx, d, seq, zctx, adaptor, statsTicker.C, s.logger, parallelism) } +func poolHasSpan(ctx context.Context, pool *lake.Pool) bool { + snap, err := pool.Log().Head(ctx) + if err != nil { + return false + } + info, err := pool.Info(ctx, snap) + if err != nil { + return false + } + return info.Span != nil +} + // A Query is the internal representation of search query describing a source // of tuples, a "search" applied to the tuples producing a set of matched // tuples, and a proc to the process the tuples