Repository navigation
Support SERIAL/BIGSERIAL non-partition columns - #673
Conversation
|
Assigned Andres Freund (@anarazel) since he'll be reviewing this. Andres Freund (@anarazel) — I thought my drop logic was working correctly, but it turns out I was connected to the wrong node in my terminal when I was testing and the sequences were not actually being dropped on the workers as I believed. Using the utility hook does not seem to capture the sequence drop portion when dropping a sequence-owning table. The event trigger seems natural, though by the time the loop informs me a sequence is being dropped, I can no longer figure out what relation it was associated with (its information in |
There was a problem hiding this comment.
Entirely independent of this change afaics.
There was a problem hiding this comment.
Yeah, citus_indent did it; I suppose I can move it to another commit.
I'm inching ever closer to having Travis builds fail if citus_indent fails.
There was a problem hiding this comment.
FWIW, I don't have a problem with making Travis fail.
Indeed. That's why the event drop trigger exists.
For simplicity a reasonable approach is to simply always replay drop |
4127a54 to
b91e817
Compare
I've pushed up the |
This elides the fact that there is no canonical set of "workers". Just the list of to-be-workers-when-shards-are-next-created in |
There was a problem hiding this comment.
It'd be a bit better to use array_agg(DISTINCT) or something, || is O(n^2).
|
Andres Freund (@anarazel) I still need to add the test you suggested, but I've addressed everything else (I think). Can you verify that I didn't miss anything? |
There was a problem hiding this comment.
Hm. Wonder if we really only want to do this with '1'.
There was a problem hiding this comment.
Huh. I could have sworn master_drop_all_shards used only finalized placements, but apparently not. Removing.
7a5a01c to
e184b3b
Compare
There was a problem hiding this comment.
We should only error out if the owner is different, lots of tools just specify all the options.
|
Some minor details to fix (added check list in PR description), other than those... |
Hooray! Thanks. |
dceab55 to
56d8f97
Compare
|
OK, everything should be addressed Andres Freund (@anarazel). Look over how I addressed everything and I can merge it all in the morning with your blessing 🙏. |
There was a problem hiding this comment.
Uh, are you sure this doesn't reset that property, given that's an earlier upgrade script? I'd much rather copy that here.
There was a problem hiding this comment.
I had the same thought, but wanted to ask you about it. If you're fine copying it here, will do so.
There was a problem hiding this comment.
(I checked BTW, and CREATE OR REPLACE apparently preserves the value of parameters not specified, so it remains SECURITY DEFINER).
There was a problem hiding this comment.
Done.
|
General uninformed question: Should we do something about sequences in append-distributed tables? They allow COPY directly from the worker and will thus use the sequences on the worker and see duplicate values. |
There was a problem hiding this comment.
Is that list_length() check correct? pg_catalog.serial is sometimes auto-generated.
There was a problem hiding this comment.
I hope so, since this is copy-pasted-edited from transformColumnDefinition. I'll add a comment.
There was a problem hiding this comment.
Done.
|
On 2016-07-28 10:52:38 -0700, Marco Slot wrote:
I don't really see what we can do about that for now, except maybe |
Marco Slot (@marcocitus): can we add a check to worker-side copy to ban any default values that contain mutable functions? If not, why not? Was this an oversight, or conscious for some use case? If so, I'll add that, which would cover this. If not, I can add a more conservative check for sequences. |
|
Jason Petersen (@jasonmp85) I've given this PR testing with the Rails app, and first of all: Looks good! However I am encountering this issue if the SERIAL column is the partition column: Should I open a separate issue for this, or is it related to this PR? |
That's expected behavior. Right now we can't evaluate You'd get a similar error before, though during shard creation. Now we let you get past shard creation, you just can't use the I had thought adding a check for this would be burdensome, but now I realize it's like one or two statements, tops. Would you like me to make a more explicit error (at shard creation—not |
|
Lukas Fittl (@lfittl) Actually, I suppose it could be at |
|
On 2016-07-28 12:42:07 -0700, Jason Petersen wrote:
It works for copy, so let's leave it the current way. |
|
On Thursday, July 28, 2016, Jason Petersen [email protected] wrote:
I don't think thats necessary - the current error is fine. I'll make a new issue so we can track this for future release planning. The Lukas Fittl Skype: lfittl |
I think I knew this right after the master functions review was merged but had since forgotten. Makes this a moot point. Added a comment to Brian Cloutier (@lithp) in #488 about this message. |
07df5c9 to
2c59e9d
Compare
|
Changes look good to me, but apparently needs a rebase with actual conflicts. |
2db194b to
3672634
Compare
|
Any updates? It's been flattened and debased, AFAIK. Jason Petersen On Jul 28, 2016, at 5:18 PM, Andres Freund [email protected] wrote: Changes look good to me, but apparently needs a rebase with actual — |
|
On 2016-07-28 18:13:40 -0700, Jason Petersen wrote:
debased? Interesting ;) I earlier basically meant to imply that you have a |
|
I was going to claim it was a Pixies reference but it's actually just Merging soon, thanks! Jason Petersen On Jul 28, 2016, at 7:16 PM, Andres Freund [email protected] wrote: On 2016-07-28 18:13:40 -0700, Jason Petersen wrote:
debased? Interesting ;) I earlier basically meant to imply that you have a — |
This adds support for SERIAL/BIGSERIAL column types. Because we now can evaluate functions on the master (during execution), adding this is a matter of ensuring the table creation step works properly. To accomplish this, I've added some logic to detect sequences owned by a table (i.e. those related to its columns). Simply creating a sequence and using it in a default value is insufficient; users who do so must ensure the sequence is owned by the column using it. Fortunately, this is exactly what SERIAL and BIGSERIAL do, which is the use case we're targeting with this feature. While testing this, I found that worker_apply_shard_ddl_command actually adds shard identifiers to sequence names, though I found no places that use or test this path. I removed that code so that sequence names are not mutated and will match those used by a SERIAL default value expression. Our use of the new-to-9.5 CREATE SEQUENCE IF NOT EXISTS syntax means we are dropping support for 9.4 (which is being done regardless, but makes this change simpler). I've removed 9.4 from the Travis build matrix. Some edge cases are possible in ALTER SEQUENCE, COPY FROM (on workers), and CREATE SEQUENCE OWNED BY. I've added errors for each so that users understand when and why certain operations are prohibited.
3672634 to
abe7304
Compare
Support SERIAL/BIGSERIAL non-partition columns cr: @anarazel
This adds support for
SERIAL/BIGSERIALcolumn types. Because we now can evaluate functions on the master (during execution), adding this is a matter of ensuring the table creation step works properly.To accomplish this, I've added some logic to detect sequences owned by a table (i.e. those related to its columns). Simply creating a sequence and using it in a default value is insufficient; users who do so must ensure the sequence is owned by the column using it.
Fortunately, this is exactly what
SERIALandBIGSERIALdo, which is the use case we're targeting with this feature. While testing this, I found thatworker_apply_shard_ddl_commandactually adds shard identifiers to sequence names, though I found no places that use or test this path. I removed that code so that sequence names are not mutated and will match those used by aSERIALdefault value expression.Our use of the new-to-9.5
CREATE SEQUENCE IF NOT EXISTSsyntax means we are dropping support for 9.4 (which is being done regardless, but makes this change simpler). I've removed 9.4 from the Travis build matrix.Fixes #211