influxdata / influxdata/influxdb
Query works directly, but does nothing as a Continuous Query
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
I have a query that works fine as a regular query, but does nothing as a continuous query, with no error message.
__Steps to reproduce:__
This query works perfectly fine, and writes the expected datapoints:
`SELECT sum(bits) INTO telegraf.autogen.test_traffic FROM (SELECT non_negative_derivative(mean(ifHCInOctets), 1s) * 8 AS bits FROM telegraf.autogen.snmp_hcinterfaces WHERE (time > now() - 1m AND agent_host = '10.42.56.4' AND ifName =~ /^reth\d+$/) GROUP BY time(1m), *) GROUP BY time(1m), agent_host, device_model, device_type, env, host, instance, minion_id, primary_role, project, site, sysName`
But as a continuous query, it does nothing:
`CREATE CONTINUOUS QUERY cq_snmp_interface_total ON telegraf RESAMPLE EVERY 1m FOR 1m BEGIN SELECT sum(bits) INTO telegraf.autogen.test_traffic FROM (SELECT non_negative_derivative(mean(ifHCInOctets), 1s) * 8 AS bits FROM telegraf.autogen.snmp_hcinterfaces WHERE (time > now() - 1m AND agent_host = '10.42.56.4' AND ifName =~ /^reth\d+$/) GROUP BY time(1m), *) GROUP BY time(1m), agent_host, device_model, device_type, env, host, instance, minion_id, primary_role, project, site, sysName END`
The logs confirm that it runs, but no data is written, and there are no error messages to suggest why it fails as a CQ.
`
Jun 26 07:43:00 influxdb-0 influxd[1721]: ts=2020-06-26T11:43:00.120238Z lvl=info msg="Continuous query execution (start)" log_id=0NAXIJ10000 service=continuous_querier trace_id=0Nd6r660000 op_name=continuous_querier_execute op_event=start
Jun 26 07:43:00 influxdb-0 influxd[1721]: ts=2020-06-26T11:43:00.120272Z lvl=info msg="Executing continuous query" log_id=0NAXIJ10000 service=continuous_querier trace_id=0Nd6r660000 op_name=continuous_querier_execute name=cq_snmp_interface_total db_instance=telegraf start=2020-06-26T11:42:00.000000Z end=2020-06-26T11:43:00.000000Z
Jun 26 07:43:00 influxdb-0 influxd[1721]: ts=2020-06-26T11:43:00.120402Z lvl=info msg="Executing query" log_id=0NAXIJ10000 service=query query="SELECT sum(bits) INTO telegraf.autogen.test_traffic FROM (SELECT non_negative_derivative(mean(ifHCInOctets), 1s) * 8 AS bits FROM telegraf.autogen.snmp_hcinterfaces WHERE (time > now() - 1m AND agent_host = '10.42.56.4' AND ifName =~ /^reth\\d+$/) GROUP BY time(1m), *) WHERE time >= '2020-06-26T11:42:00Z' AND time < '2020-06-26T11:43:00Z' GROUP BY time(1m), agent_host, device_model, device_type, env, host, instance, minion_id, primary_role, project, site, sysName"
Jun 26 07:43:00 influxdb-0 influxd[1721]: ts=2020-06-26T11:43:00.125790Z lvl=info msg="Finished continuous query" log_id=0NAXIJ10000 service=continuous_querier trace_id=0Nd6r660000 op_name=continuous_querier_execute name=cq_snmp_interface_total db_instance=telegraf written=0 start=2020-06-26T11:42:00.000000Z end=2020-06-26T11:43:00.000000Z duration=5ms
Jun 26 07:43:00 influxdb-0 influxd[1721]: ts=2020-06-26T11:43:00.125848Z lvl=info msg="Continuous query execution (end)" log_id=0NAXIJ10000 service=continuous_querier trace_id=0Nd6r660000 op_name=continuous_querier_execute op_event=end op_elapsed=5.621ms`
__Expected behavior:__
Data points should be written to telegraf.autogen.test_traffic as they are when the same query is called directly
__Actual behavior:__
Nothing happens. The CQ runs, but writes zero datapoints
__Environment info:__
* System info: Linux 3.10.0-1062.12.1.el7.x86_64 x86_64
* InfluxDB version: InfluxDB v1.7.9 (git: 1.7 23bc63d43a8dc05f53afa46e3526ebb5578f3d88)
__Config:__
No unusual config
Contributor guide
Research direction
Start by reproducing the continuous query with the supplied InfluxDB v1.7.9 queries and compare its execution with the direct query. Inspect the continuous-query execution path and its logged time window; done means the CQ writes the expected datapoints to telegraf.autogen.test_traffic and reports a nonzero written count.
Written by the indexing model from the issue text.
Assessment
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100