citusdata / citusdata/citus

Update in normal table subquerying a distributed table raises an error

Open
#6,233 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Citus version `Citus 11.0.3 on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit`

I have a distributed table with total relation size of 2671 GB, with +560 million rows within a 2 node cluster, like this

```sql
SELECT citus_set_coordinator_host('192.168.0.2', 5432);
SELECT * FROM citus_set_node_property('192.168.0.2', 5432, 'shouldhaveshards', true);
SELECT * from citus_add_node('192.168.0.3', 5432);
```

The simplified structure of the issue that I'm facing is like the following example, but this example doesn't trigger the error

```sql
CREATE TABLE distributed_test_table(id int, json_data jsonb, last_update timestamp);
SELECT create_distributed_table('distributed_test_table', 'id', shard_count => 192);
CREATE INDEX idx_distributed_test_table_last_update on distributed_test_table(last_update desc);

CREATE TABLE test_table (name text, previous_col text, col text);

insert into distributed_test_table values (1, null, now());
insert into test_table values ('config', '','');

update test_table
set previous_col = col,
col = (select max(last_update) from distributed_test_table)
where name = 'config'
returning col;
ERROR: functions used in UPDATE queries on distributed tables must not be VOLATILE

with cte as (select max(last_update)::text as last_id from distributed_test_table)
update test_table set previous_col = col, col = b.last_id
from cte as b
where name = 'config'
returning col;
ERROR: functions used in UPDATE queries on distributed tables must not be VOLATILE
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.