Seems these files were created on non-unix platform so EOL is missing.
This is not an issue but for consistence with other files, it's better
to add eol.
This commit changes the SeriesIDSet merge/union/intersect functions
to attach the underlying iterators as closers so that files can be
retained until the data is no longer in use. The roaring operations
can leave containers pointing at mmap data in the resulting bitmap
so we have to track underlying file usage until the data is finished
with.
This commit changes `DefaultSeriesIDSetCacheSize` to zero so that the
tag value cache is disabled by default. There is a rare known bug where
the cache can cause a segfault which crasheds the process. The cache
is being disabled instead of removed as some users may still need the
cache for performance reasons.
Quiet staicccheck warning "should merge variable declaration with
assignment on next line (S1021)" by updating point.gen.go.tmpl and
re-generating point.gen.go.
When comparing strings in a case-insensitive way, strings.EqualFold() is
(almost?) always faster than comparing the results of strings.ToLower().
In addition, strings.EqualFold() never causes an allocation.
This patch replaces case-insensitive string comparisons that use
strings.ToLower() with a strings.EqualFold() call.
matchAllRegex is a global variable containing the precompiled regex that
matches ".+".
Prior to this commit, it was used in only one place and we called its
.Copy() method.
According to the docs, .Copy() is no longer needed for safe concurrent
access:
Deprecated: In earlier releases, when using a Regexp in multiple
goroutines, giving each goroutine its own copy helped to avoid lock
contention. As of Go 1.12, using Copy is no longer necessary to avoid
lock contention. Copy may still be appropriate if the reason for its
use is to make two copies with different Longest settings.
Since we require Go 1.13 or later now and we're not calling the
Longest() method, this patch removes the .Copy() call.
Now that we have a reusable matchAllRegex value, this patch then
replaces all instances of regexp.MustCompile(`.+`) with matchAllRegex.
This will elminate runtime regex compilations.
Instead of type converting the Body.Bytes() to a string, we can simply
call Body.String().
While we're at it, this patch also uses a simple string comparison
instead of cmp.Equal() for two strings.
According to the docs, they're equivalent.
Prior to this commit, we passed a nil context to the .QueryCtx() and
.createDefaultRequest() methods.
Using any of the context.Context method-set against a nil value will
cause a panic.
This patch passest context.Background() instead of nil.
Closes: 18137
This commit quiets staticcheck's warnings about "unnecessary use of
fmt.Sprintf" and "unnecessary use of fmt.Sprint".
Prior to this commit we were wrapping simple constant strings without
any formatting verbs with fmt.Sprintf().
* fix(tsdb): address staticcheck ST1006
This patch addresses staticcheck warning "receiver name should not be an
underscore, omit the name if it is unused (ST1006)" for 6 methods.
Before this commit, the to and from variables were being re-declared in
a block in such a way that the values were not being used.
This patch uses regular assignment so that the values are visable
outside of the block where they're set.
Closes: 18128
Sorted merge iterator has cpu-intensive operations to sort the points
from multiple inputs. Typical queries like `SELECT * FROM m GROUP BY *`
do not behave well due to the comparison of points though in many cases
it doesn't necessarily have to use the slow path.
This patch adds a shortcut. If each input has a single and unique
series we can just return the points input by input.
The detection of the shortcut introduces slight overhead but the gains
are significant in many slow queries.
* fix: verify precision parameter in write requests
This change updates the HTTP endpoints that service v1 and v2 writes to
verify the values passed in the precision parameter.
* fix(tsm1): Fix temp directory search bug
The original code's intention is to scan a directory for the directory
with the higest value when converted to an integer.
So directories may be in the form:
0.tmp
1.tmp
2.tmp
30.tmp
...
100.tmp
The loop should scan the directory, strip the basename and extension
from the file name to leave just a number, then store the higest number
it finds.
Before this patch, there is a bug that has the code only store the
higest value if there is an error converting the numeric value into an
integer.
This patch primarily fixes that logic.
In addition, this patch will save an indent level by inverting logic in
two places:
Instead if checkig if a file is a directory and has a suffix of ".tmp",
it is probably better to test if a file is NOT a directory OR does NOT
have an extension of ".tmp" then continue.
Also, instead of testig if len(ss) == 2, we can test if len(ss) != 2 and
continue if so.
Both of these save an indent level and keeps our "happy path" to the
left.
Finally, this patch will use string concatination instead of calling
fmt.Sprintf() to add periods to "tmp" and "tsm" extension.
Co-authored-by: David Norton <dgnorton@gmail.com>
Have AuthorizerIsOpen() assert if a given authizer has an
AuthorizeUnrestricted() method and if so, call that to provide the
result of AuthorizerIsOpen().
Otherwise we check if the supplied Authorizer is nil.
This preserves the fast-path for checking tag-level (and other) tsdb
operations.
This simplifies how we handle such authorizers by handling this case in
only one place.
fixes#17440
While encoding or decoding corrupt data, the current behaviour is to `panic`.
This commit replaces the `panic` with `error` to be propagated up to the calling `iterator`.
To avoid overwriting other `error`, iterators now wraps a `TSMErrors` which contains ALL the encountered errors.
TSMErrors itself implements `Error()`, the returned string contains all the error msgs, separated by "," delimiter.
We neglected to update the go version to 1.13 when we converted to
modules.
We plan on using 1.13 features like error wrapping so it is important
that this is correct for 1.8.x.
This is a fix and a bit of a refactor of Service.readRequest().
This commit changes the signature so that it accepts an io.Reader
instead of a net.Conn because there's nothing about the function that
relies on it being a Conn; only a Reader.
We also changed the signature so that it returns a *Request instead of
Request -- this way we don't allocate an entire Request value on error.
This commit also attempts to document the few edge cases that the function has to
handle and one quirk where we expect to read a newline which isn't
accounted for by Request.UploadSize.