Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Bug ] multi node: bind message supplies 0 parameters, but prepared statement "" requires 1 #3974

Closed
daydayup863 opened this issue Jan 11, 2022 · 3 comments · Fixed by #4176
Assignees

Comments

@daydayup863
Copy link

What type of bug is this?

Unexpected error

What subsystems and features are affected?

Multi-node

What happened?

set timescaledb.enable_remote_explain to on;
execute explain (verbose) report ERROR bind message supplies 0 parameters, but prepared statement "" requires 1

TimescaleDB version affected

2.5.1

PostgreSQL version used

14.1

What operating system did you use?

CentOS 7.6.1810

What installation method did you use?

Source

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

k8s_prometheus_beta_cn0z2=# set timescaledb.enable_remote_explain to on;
SET
Time: 0.203 ms
k8s_prometheus_beta_cn0z2=# explain (verbose) SELECT series.labels,  result.time_array, result.value_array
                FROM "prom_data_series"."container_cpu_usage_seconds_total" series
                INNER JOIN LATERAL (
                        SELECT array_agg(time) as time_array, array_agg(value) as value_array
                        FROM
                        (
                                SELECT time, "value" as value
                                FROM "prom_data"."container_cpu_usage_seconds_total" metric
                                WHERE metric.series_id = series.id
                                AND time >= '2022-01-11T05:58:00Z'
                                AND time <= '2022-01-11T06:01:00Z'
                                ORDER BY time
                        ) as time_ordered_rows
                ) as result ON (result.value_array is not null) 
                WHERE
                     labels && (SELECT COALESCE(array_agg(l.id), array[]::int[]) FROM _prom_catalog.label l WHERE l.key = 'job' and l.value = 'kubelet') ;
ERROR:  [k8spgdb2]: bind message supplies 0 parameters, but prepared statement "" requires 1
Time: 4.990 ms
k8s_prometheus_beta_cn0z2=# 
k8s_prometheus_beta_cn0z2=# 
k8s_prometheus_beta_cn0z2=# set timescaledb.enable_remote_explain to off;
SET
Time: 0.212 ms
k8s_prometheus_beta_cn0z2=# 
k8s_prometheus_beta_cn0z2=# explain (verbose) SELECT series.labels,  result.time_array, result.value_array
                FROM "prom_data_series"."container_cpu_usage_seconds_total" series
                INNER JOIN LATERAL (
                        SELECT array_agg(time) as time_array, array_agg(value) as value_array
                        FROM
                        (
                                SELECT time, "value" as value
                                FROM "prom_data"."container_cpu_usage_seconds_total" metric
                                WHERE metric.series_id = series.id
                                AND time >= '2022-01-11T05:58:00Z'
                                AND time <= '2022-01-11T06:01:00Z'
                                ORDER BY time
                        ) as time_ordered_rows
                ) as result ON (result.value_array is not null) 
                WHERE
                     labels && (SELECT COALESCE(array_agg(l.id), array[]::int[]) FROM _prom_catalog.label l WHERE l.key = 'job' and l.value = 'kubelet') ;
                                                                                                                                                                                    QUERY PLAN                                                                                            
                                                                                        
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
 Nested Loop  (cost=129971.36..53157666.70 rows=409 width=149)
   Output: series.labels, (array_agg(metric."time")), (array_agg(metric.value))
   InitPlan 1 (returns $0)
     ->  Aggregate  (cost=3.44..3.45 rows=1 width=32)
           Output: COALESCE(array_agg(l.id), '{}'::integer[])
           ->  Index Only Scan using label_key_value_id_key on _prom_catalog.label l  (cost=0.42..3.44 rows=1 width=4)
                 Output: l.key, l.value, l.id
                 Index Cond: ((l.key = 'job'::text) AND (l.value = 'kubelet'::text))
   ->  Seq Scan on prom_data_series.container_cpu_usage_seconds_total series  (cost=0.00..777.83 rows=409 width=93)
         Output: series.id, series.metric_id, series.labels, series.delete_epoch
         Filter: ((series.labels)::integer[] && $0)
   ->  Aggregate  (cost=129967.91..129967.92 rows=1 width=64)
         Output: array_agg(metric."time"), array_agg(metric.value)
         Filter: (array_agg(metric.value) IS NOT NULL)
         ->  Sort  (cost=129967.88..129967.89 rows=1 width=16)
               Output: metric."time", metric.value
               Sort Key: metric."time"
               ->  Custom Scan (DataNodeScan) on prom_data.container_cpu_usage_seconds_total metric  (cost=100.00..129967.87 rows=1 width=16)
                     Output: metric."time", metric.value
                     Data node: l-k8spgdb2.ops.cn1
                     Chunks: _dist_hyper_345_64508_chunk
                     Remote SQL: SELECT "time", value FROM prom_data.container_cpu_usage_seconds_total WHERE _timescaledb_internal.chunks_in(prom_data.container_cpu_usage_seconds_total.*, ARRAY[6237]) AND (("time" >= '2022-01-11 13:58:00+08'::timestamp with time zone)) AND (("time"
 <= '2022-01-11 14:01:00+08'::timestamp with time zone)) AND ((series_id = $1::bigint))
 Query Identifier: -5271016163191226258
(23 rows)

Time: 2.259 ms

How can we reproduce the bug?

No response

@daydayup863 daydayup863 changed the title multi node: bind message supplies 0 parameters, but prepared statement "" requires 1 [ BUG ] multi node: bind message supplies 0 parameters, but prepared statement "" requires 1 Jan 11, 2022
@daydayup863 daydayup863 changed the title [ BUG ] multi node: bind message supplies 0 parameters, but prepared statement "" requires 1 [ Bug ] multi node: bind message supplies 0 parameters, but prepared statement "" requires 1 Jan 11, 2022
@pmwkaa pmwkaa self-assigned this Jan 13, 2022
@pmwkaa
Copy link
Contributor

pmwkaa commented Jan 14, 2022

@daydayup863 There is a chance that this might be fixed by 4aeb133. Unfortunately I was not able to find a way to reproduce it for me, if you could provide a more detailed steps to do it it would be a great help

@daydayup863
Copy link
Author

daydayup863 commented Jan 18, 2022

@daydayup863 There is a chance that this might be fixed by 4aeb133. Unfortunately I was not able to find a way to reproduce it for me, if you could provide a more detailed steps to do it it would be a great help

this way can reproduce it:

k8s_prometheus_beta_cn0z2=# CREATE TABLE conditions (                                                                                                                        
   time        TIMESTAMPTZ       NOT NULL,
   location    TEXT              NOT NULL,
   temperature DOUBLE PRECISION  NULL,
   humidity    DOUBLE PRECISION  NULL
);
CREATE TABLE
k8s_prometheus_beta_cn0z2=# SELECT create_distributed_hypertable('conditions', 'time', 'location');
 create_distributed_hypertable 
-------------------------------
 (1355,public,conditions,t)
(1 row)

k8s_prometheus_beta_cn0z2=# insert into conditions select '2022-01-18 00:00:00'::timestamptz + (i || ' sec')::interval  , md5(i::text), i, i from generate_series(1, 10000) i;
INSERT 0 10000
k8s_prometheus_beta_cn0z2=#  set timescaledb.enable_remote_explain to on;
SET
k8s_prometheus_beta_cn0z2=#  explain (verbose) SELECT location,  result.time_array, result.value_array
                FROM conditions series
                INNER JOIN LATERAL (
                        SELECT array_agg(time) as time_array, array_agg(humidity) as value_array
                        FROM
                        (
                                SELECT time, humidity as humidity
                                FROM conditions metric
                                WHERE metric.location = series.location
                                AND time >= '2022-01-18T05:58:00Z'
                                AND time <= '2022-01-19T06:01:00Z'
                                ORDER BY time
                        ) as time_ordered_rows
                ) as result ON (result.value_array is not null) 
               ;
ERROR:  [l-k8spgdb1.ops.cn1]: bind message supplies 0 parameters, but prepared statement "" requires 1

@nikkhils
Copy link
Contributor

@daydayup863 the issue here is that the LATERAL query ends up using a parameterized query on the datanode. Now the postgres EXPLAIN command is not used to dealing with such kind of parameterized queries and hence it barfs with the above bind message 0 parameters error.

@nikkhils nikkhils self-assigned this Mar 16, 2022
nikkhils added a commit to nikkhils/timescaledb that referenced this issue Mar 17, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes timescale#3974

Reported and test case provided by @daydayup863
nikkhils added a commit to nikkhils/timescaledb that referenced this issue Mar 17, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes timescale#3974

Reported and test case provided by @daydayup863
nikkhils added a commit to nikkhils/timescaledb that referenced this issue Mar 21, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes timescale#3974

Reported and test case provided by @daydayup863
nikkhils added a commit that referenced this issue Mar 21, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes #3974

Reported and test case provided by @daydayup863
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 5, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih pushed a commit to RafiaSabih/timescaledb that referenced this issue Apr 5, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes timescale#3974

Reported and test case provided by @daydayup863
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 6, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih pushed a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes timescale#3974

Reported and test case provided by @daydayup863
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
mkindahl pushed a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes timescale#3974

Reported and test case provided by @daydayup863
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit to RafiaSabih/timescaledb that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#3974 Fix remote EXPLAIN with parameterized queries
* timescale#4122 Fix segfault on INSERT into distributed hypertable
* timescale#4142 Ignore invalid relid when deleting hypertable
* timescale#4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* timescale#4161 Fix memory handling during scans
* timescale#4186 Fix owner change for distributed hypertable
* timescale#4192 Abort sessions after extension reload
* timescale#4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
RafiaSabih added a commit that referenced this issue Apr 8, 2022
This release is patch release. We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #3974 Fix remote EXPLAIN with parameterized queries
* #4122 Fix segfault on INSERT into distributed hypertable
* #4142 Ignore invalid relid when deleting hypertable
* #4159 Fix ADD COLUMN IF NOT EXISTS error on compressed hypertable
* #4161 Fix memory handling during scans
* #4186 Fix owner change for distributed hypertable
* #4192 Abort sessions after extension reload
* #4193 Fix relcache callback handling causing crashes

**Thanks**
* @abrownsword for reporting a crash in the telemetry reporter
* @daydayup863 for reporting issue with remote explain
svenklemm pushed a commit that referenced this issue Apr 11, 2022
In certain multi-node queries, we end up using a parameterized query
on the datanodes. If "timescaledb.enable_remote_explain" is enabled we
run an EXPLAIN on the datanode with the remote query. EXPLAIN doesn't
work with parameterized queries. So, we check for that case and avoid
invoking a remote EXPLAIN if so.

Fixes #3974

Reported and test case provided by @daydayup863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants