You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But when we try to create empty shard we get error:
# select master_create_empty_shard( 'offers' );
WARNING: could not receive query results from citus-work1:9701
DETAIL: Client error: relation "offers_id_seq" does not exist
WARNING: could not create shard on "citus-work1:9701"
WARNING: could not receive query results from citus-work2:9701
DETAIL: Client error: relation "offers_id_seq" does not exist
WARNING: could not create shard on "citus-work2:9701"
ERROR: could only create 0 of 2 of required shard replicas
That is because of the id column:
id | integer | not null default nextval('offers_id_seq'::regclass)
Do not allow to distribute tables with serial type.
This issue is related to serial type not being supported. We have 2 issues related to this one #211 is about the issue you are describing, #213 is about a feature that offers a fix for this one too.
Unfortunately the fix for #213 won't cover this. Even though nextval() will be supported, when we try to create shards the worker fails on not null default nextval('offers_id_seq'::regclass).
Fixes:
Also push down sequence creation so the workers get their own (unused) sequences
Notice SERIAL and emit modified DML commands to the workers, they only see an not null type
With #488 merged, serial can now be used in distributed tables, provided that the user also creates the sequence on all the workers and that it is not the partition column.
If the sequences do not exist on the worker, master_create_worker_shards errors out because it does not recognize the sequence reference in the create table command (e.g. "id int not null default nextval('events_id_seq')"), but the sequences on the workers are never actually used, since nextval is evaluated by the master. If the partition column is serial, INSERT will error out, though COPY will work.
A way of addressing the master_create_worker_shards error would be to strip the default value from create table statement used to create shard placements. When we do an INSERT or COPY, we send all columns with the default filled in even if the user only provided a subset, so there is no need for the workers to know about default values.
We should also add a check to master_create_distributed_table to error out if there is a non-constant expression in the partition column.
I think we can now create a distributed table that has a SERIAL column, without asking the user to create sequences on workers. Does that align with your understanding as well? If so, I'm planning to close this issue.
(We have a separate issue related to using a SERIAL column for distribution in #687. We'll keep that one open.)
Activity
KES777 commentedon May 10, 2016
Ambiguous because it is not clear: the tables with serial type not supported or master_create_empty_shard does not distribute required info.
[-]ambigious behaviour not covered in the doc[/-][+]Ambiguous behaviour not covered in the doc[/+]mtuncer commentedon May 10, 2016
Hey Eugen Konkov (@KES777)
This issue is related to serial type not being supported. We have 2 issues related to this one
#211 is about the issue you are describing, #213 is about a feature that offers a fix for this one too.
[-]Ambiguous behaviour not covered in the doc[/-][+]Support for SERIAL type[/+]lithp commentedon May 24, 2016
Unfortunately the fix for #213 won't cover this. Even though nextval() will be supported, when we try to create shards the worker fails on
not null default nextval('offers_id_seq'::regclass).Fixes:
not nulltypemarcocitus commentedon Jul 15, 2016
With #488 merged, serial can now be used in distributed tables, provided that the user also creates the sequence on all the workers and that it is not the partition column.
If the sequences do not exist on the worker, master_create_worker_shards errors out because it does not recognize the sequence reference in the create table command (e.g. "id int not null default nextval('events_id_seq')"), but the sequences on the workers are never actually used, since nextval is evaluated by the master. If the partition column is serial, INSERT will error out, though COPY will work.
A way of addressing the master_create_worker_shards error would be to strip the default value from create table statement used to create shard placements. When we do an INSERT or COPY, we send all columns with the default filled in even if the user only provided a subset, so there is no need for the workers to know about default values.
We should also add a check to master_create_distributed_table to error out if there is a non-constant expression in the partition column.
ozgune commentedon Jan 3, 2017
Marco Slot (@marcocitus) -- I'm sifting through our old issues and had a question on this one.
I think we can now create a distributed table that has a
SERIALcolumn, without asking the user to create sequences on workers. Does that align with your understanding as well? If so, I'm planning to close this issue.(We have a separate issue related to using a
SERIALcolumn for distribution in #687. We'll keep that one open.)marcocitus commentedon Jan 4, 2017
Yep, fixed by #673