Commit Graph

11452 Commits (72e4dd01b95726d5fafa767e696e91fb93c3ded6)

Author SHA1 Message Date
Jonathan A. Sternberg 72e4dd01b9 Properly select a tag within a subquery
Previously, subqueries would only be able to select tag fields within a
subquery if the subquery used a selector. But, it didn't filter out
aggregates like `mean()` so it would panic instead.

Now it is possible to select the tag directly instead of rewriting the
query in an invalid way.

Some queries in this form will still not work though. For example, the
following still does not function (but also doesn't panic):

    SELECT count(host) FROM (SELECT mean, host FROM (SELECT mean(value) FROM cpu GROUP BY host))
2017-02-23 11:16:22 -06:00
Jonathan A. Sternberg 05fcf04236 Merge pull request #8052 from influxdata/js-8040-paren-expr-subquery-panic
Reduce the expression in a subquery to avoid a panic
2017-02-23 11:15:56 -06:00
Jonathan A. Sternberg 5a2b458180 Reduce the expression in a subquery to avoid a panic
The builder used for subqueries does not handle parenthesis, but a set
of parenthesis wrapping a field would cause it to panic. This code now
reduces the expression so the parenthesis are removed before being
processed.
2017-02-23 10:14:05 -06:00
Jason Wilder 5c1d97e4a0 Merge pull request #8038 from influxdata/jw-merge-11
Remove Tags.shouldCopy, replace with forceCopy on series creation.
2017-02-21 11:46:58 -07:00
Ben Johnson 78a9bb2527 Remove Tags.shouldCopy, replace with forceCopy on series creation.
Previously, tags had a `shouldCopy` flag to indicate if those tags
referenced an underlying buffer and should be copied to allow GC.
Unfortunately, this prevented tags from being copied that were
created and referenced the mmap which caused segfaults.

This change removes the `shouldCopy` flag and replaces it with a
`forceCopy` argument in `CreateSeriesIfNotExists()`. This allows
the write path to indicate that tags must be cloned on insert.
2017-02-21 11:13:35 -07:00
Jonathan A. Sternberg 7c23d6869c Merge pull request #8029 from influxdata/js-rename-zap-import
Rename zap import back to github.com/uber-go/zap
2017-02-17 17:28:06 -06:00
Jonathan A. Sternberg 2fe48d6781 Rename zap import back to github.com/uber-go/zap
They rebased a revision we were previously relying upon that allowed us
to use the vanity name so we are reverting back to an older version with
the old import path.
2017-02-17 17:17:22 -06:00
Ben Johnson bae0987711 Merge pull request #8011 from benbjohnson/fix-series-tags-map
Fix tag dereferencing panic.
2017-02-15 18:25:02 -07:00
Ben Johnson 8e79ca5d75
Fix tag dereferencing panic.
Clones series tags under lock during var ref iterator creation.
2017-02-15 17:56:47 -07:00
Jonathan A. Sternberg 0e0057d1da Merge pull request #8002 from influxdata/js-8001-map-types-with-empty-measurement
Map types correctly when using a regex and one of the measurements is empty
2017-02-13 18:24:30 -06:00
Jonathan A. Sternberg 71f62d33e6 Map types correctly when using a regex and one of the measurements is empty 2017-02-13 18:14:29 -06:00
Jonathan A. Sternberg afbfa0086f Merge pull request #7966 from influxdata/js-7898-prevent-panic-when-aggregate-returns-no-aux-fields
Prevent a panic when aggregates are used in an inner query with a raw query
2017-02-08 12:49:14 -06:00
Jonathan A. Sternberg 2ad1668c2a Prevent a panic when aggregates are used in an inner query with a raw query
The following types of queries will panic:

    SELECT mean, host FROM (SELECT mean(value) FROM cpu GROUP BY host)
    SELECT top(sum, host, 3) FROM (SELECT sum(value) FROM cpu GROUP BY host)

These queries _should_ work, but due to a current limitation with
aggregate functions, the aggregate functions won't return any auxiliary
fields. So even if a tag is not an auxiliary field, it is treated that
way by the query engine and this query will fail.

Fixing this properly will take a longer period of time. This fix just
prevents the panic from killing the server while we fix this for real.
2017-02-08 11:44:56 -06:00
Jonathan A. Sternberg b3930f2a3f Merge pull request #7907 from influxdata/js-7905-order-by-desc-fix
Fix ORDER BY time DESC with ordering series keys
2017-02-06 15:57:35 -06:00
Jonathan A. Sternberg e1fa48d0dd Fix ORDER BY time DESC with ordering series keys
The order of series keys is in ascending alphabetical order, not
descending alphabetical order, when it is ordered by descending time.
This fixes the ordering so points are returned in descending order. The
emitter also had the conditions for choosing which iterator to use in
the wrong direction (which only affects aggregates with `FILL(none)`).
2017-02-06 15:49:12 -06:00
Jonathan A. Sternberg 11a49db662 Merge pull request #7954 from influxdata/js-7885-fix-limit-and-offset-in-subqueries
Fix LIMIT and OFFSET when they are used in a subquery
2017-02-06 15:46:49 -06:00
Jonathan A. Sternberg 95831b3307 Fix LIMIT and OFFSET when they are used in a subquery
This fixes LIMIT and OFFSET when they are used in a subquery where the
grouping of the inner query is different than the grouping of the outer
query. When organizing tag sets, the grouping of the outer query is
used so the final result is in the correct order. But, unfortunately,
the optimization incorrectly limited the number of points based on the
grouping in the outer query rather than the grouping in the inner query.

The ideal solution would be to use the outer grouping to further
organize it by the grouping for the inner subquery, but that's more
difficult to do at the moment. As an easier fix, the query engine now
limits the output of each series. This may result in these types of
queries being slower in some situations like this one:

    SELECT mean(value) FROM (SELECT value FROM cpu GROUP BY host LIMIT 1)

This will be slower in a situation where the `cpu` measurement has a
high cardinality and many different tags.

This also fixes `last()` and `first()` when they are used in a subquery
because those functions use `LIMIT 1` as an internal optimization.
2017-02-06 14:04:34 -06:00
Jonathan A. Sternberg 4d97dd495d Merge pull request #7952 from influxdata/js-7946-subquery-authorization
Fix authentication when subqueries are present
2017-02-06 14:03:50 -06:00
Jonathan A. Sternberg caaad60dcf Fix authentication when subqueries are present
The code that checked if a query was authorized did not account for
sources that were subqueries. Now, the check for the required privileges
will descend into the subquery and add the subqueries required
privileges to the list of required privileges for the entire query.
2017-02-06 09:43:14 -06:00
Jonathan A. Sternberg d5ac69be6f Merge pull request #7937 from influxdata/js-7895-incorrect-calculations-math-with-aggregates
Fix incorrect math when aggregates that emit different times are used
2017-02-02 16:02:27 -06:00
Jonathan A. Sternberg e49ba016fa Fix incorrect math when aggregates that emit different times are used
When using `non_negative_derivative()` and `last()` in a math aggregate
with each other, the math would not be matched with each other because
one of those aggregates would emit one fewer point than the others. The
math iterators have been modified so they now track the name and tags of
a point and match based on those.

This isn't necessarily ideal and may come to bite us in the future. We
don't necessarily have a defined structure for all iterators so it can
be difficult to know which of two points is supposed to come first in
the ordering. This uses the common ordering that usually makes sense,
but the query engine is getting complicated enough where I am not 100%
certain that this is correct in all circumstances.
2017-02-02 14:40:41 -06:00
joelegasse b0abd6a23b Merge pull request #7934 from influxdata/jl-regex-case#7906
regex: don't use exact match for case insensitive expression
2017-02-02 10:53:35 -05:00
Joe LeGasse 37d4973609 updated CHANGELOG 2017-02-02 10:25:32 -05:00
Joe LeGasse 93d18d42a6 regex: don't use exact match for case insensitive expression
Fixes #7906

In an attempt to reduce the overhead of using regex for exact matches,
the query parser will replace `=~ /^thing$/` with `== 'thing'`, but the
conditions being checked would ignore if any flags were set on the
expression, so `=~ /(?i)^THING$/` was replaced with `== 'THING'`, which
will fail unless the case was already exact. This change ensures that no
flags have been changed from those defaulted by the parser.
2017-02-02 10:25:08 -05:00
Ben Johnson dc36f9f7aa Merge pull request #7929 from benbjohnson/tag-iteration-sigsegv
Fix series tag iteration segmentation fault
2017-02-01 19:02:45 -07:00
Ben Johnson faef0a99c9
Perform series tag iteration under lock.
Adds a `tsdb.Series.ForEachTag()` function for safely iterating
over a series' tags within the context of a lock. This preverts
tags from being dereferenced during iteration which can cause
a seg fault.
2017-02-01 16:25:53 -07:00
Cory LaNou 8e14f0173b Merge pull request #7924 from influxdata/cjl-7880-elapsed-panic
fix panic in query execution
2017-02-01 12:03:39 -06:00
Jonathan A. Sternberg 9b0e696deb Merge pull request #7919 from influxdata/js-7910-backport
Fix EvalType when a parenthesis expression is used
2017-02-01 12:01:15 -06:00
Cory LaNou e3e319a176 fix panic in query execution 2017-02-01 10:51:26 -06:00
Jonathan A. Sternberg e060fd0aa3 Fix EvalType when a parenthesis expression is used
It did not descend into the expression within the parenthesis correctly
and would just recurse infinitely on itself instead.
2017-01-31 10:35:21 -06:00
Jonathan A. Sternberg ae8a553b7c Merge pull request #7888 from influxdata/js-7875-expand-query-dimensions-from-subquery
Expand query dimensions from the subquery
2017-01-25 16:18:05 -06:00
Jonathan A. Sternberg 92c5d336b4 Expand query dimensions from the subquery
During development, I, at some point, decided that the dimensions should
be expanded based on what was available rather than what was present in
the subquery. I don't really know the rationale for this because I
forgot, but it doesn't make sense or seem to be particularly useful.

Expanding dimensions now just uses the values specified in the subquery
rather than expanding to all available dimensions of the measurement in
the subquery.
2017-01-25 16:02:37 -06:00
Jonathan A. Sternberg b64287e95a Merge pull request #7881 from influxdata/js-7877-map-types-with-regex-measurements
Fix mapping of types when the measurement uses a regex
2017-01-25 12:49:52 -06:00
Jonathan A. Sternberg 552408c949 Fix mapping of types when the measurement uses a regex
With the new shard mapper implementation, regexes were just ignored so
it attempted to look up the field type inside of a measurement with no
name (which cannot possibly exist) so it would think the field didn't
exist and map it as the unknown type.
2017-01-25 09:49:51 -06:00
Jason Wilder b7bb7e8359 Update 1.2.0 release date 2017-01-23 20:01:48 -07:00
Jonathan A. Sternberg 17b3a759c0 Merge pull request #7870 from influxdata/js-1.2-subquery-fix-backports
Backport #7841 and #7846 to 1.2
2017-01-23 15:14:34 -06:00
Jonathan A. Sternberg 83c6d53294 Support the WHERE clause in outer queries with subqueries 2017-01-23 15:01:32 -06:00
Jonathan A. Sternberg 3d4d9062a0 Update subqueries so groupings are propagated to inner queries
Previously, only time expressions got propagated inwards. The reason for
this was simple. If the outer query was going to filter to a specific
time range, then it would be unnecessary for the inner query to output
points within that time frame. It started as an optimization, but became
a feature because there was no reason to have the user repeat the same
time clause for the inner query as the outer query. So we allowed an
aggregate query with an interval to pass validation in the subquery if
the outer query had a time range. But `GROUP BY` clauses were not
propagated because that same logic didn't apply to them. It's not an
optimization there. So while grouping by a tag in the outer query
without grouping by it in the inner query was useless, there wasn't any
particular reason to care.

Then a bug was found where wildcards would propagate the dimensions
correctly, but the outer query containing a group by with the inner
query omitting it wouldn't correctly filter out the outer group by. We
could fix that filtering, but on further review, I had been seeing
people make that same mistake a lot. People seem to just believe that
the grouping should be propagated inwards. Instead of trying to fight
what the user wanted and explicitly erase groupings that weren't
propagated manually, we might as well just propagate them for the user
to make their lives easier. There is no useful situation where you would
want to group into buckets that can't physically exist so we might as
well do _something_ useful.

This will also now propagate time intervals to inner queries since the
same applies there. But, while the interval propagates, the following
query will not pass validation since it is still not possible to use a
grouping interval with a raw query (even if the inner query is an
aggregate):

    SELECT * FROM (SELECT mean(value) FROM cpu) WHERE time > now() - 5m GROUP BY time(1m)

This also means wildcards will behave a bit differently. They will
retrieve dimensions from the sources in the inner query rather than just
using the dimensions in the group by.

Fixing top() and bottom() to return the correct auxiliary fields.
Unfortunately, we were not copying the buffer with the auxiliary fields
so those values would be overwritten by a later point.
2017-01-23 15:01:19 -06:00
Edd Robinson a67b5457f5 Merge pull request #7869 from influxdata/er-rp-validate-1.2
[Backport 1.2] #7866
2017-01-23 19:36:12 +00:00
Edd Robinson 89ccc852b6 Merge pull request #7868 from influxdata/er-rp-1.2
[Backport 1.2] Fixes #7860.
2017-01-23 19:19:40 +00:00
Edd Robinson d30819b978 Ensure rp names validated in CREATE DATABASE WITH 2017-01-23 19:18:07 +00:00
Jason Wilder 3cdb3fe23c Merge pull request #7867 from influxdata/jw-backport-7836
backport: allow partial writes on field conflicts
2017-01-23 12:07:03 -07:00
Edd Robinson 63562d9fd5 Fixes #7860.
Fix a regression introduced in #7449.

This commit ensures that create database with retention policy will work
correctly.
2017-01-23 19:01:13 +00:00
Cory LaNou d54a955068 allow partial writes on field conflicts 2017-01-23 11:54:46 -07:00
Edd Robinson 5a8e3ee6d6 Merge pull request #7851 from influxdata/er-double-rlock-1.2
[1.2] Backport #7847
2017-01-17 10:54:39 -08:00
Edd Robinson 320c5981cb Fixes racy locking on measurement 2017-01-17 09:44:56 -08:00
Edd Robinson c46212d7a2 Merge pull request #7840 from influxdata/er-subscriber-1.2
[1.2] Backport #7839
2017-01-14 20:06:58 +00:00
Edd Robinson c47be5bb56 Ensure subscriber service respects config 2017-01-13 22:15:01 +00:00
Mark Rushakoff 63e5bae7b8 Merge pull request #7832 from influxdata/mr-fix-http-write-memory-leak
Fix memory leak of retained HTTP write payloads
2017-01-13 12:04:24 -08:00
Joe LeGasse cd00085e9e Adjust Tags cloning
This change delays Tag cloning until a new series is found, and will
only clone Tags acquired from `ParsePoints...` and not those referencing
the mmap-ed files (TSM) that are created on startup.
2017-01-13 13:15:36 -05:00