-
Notifications
You must be signed in to change notification settings - Fork 78
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
Unable to copy target table data to source when target partitioned #700
Comments
Is my understanding correct that the table (here |
The same problem we have encountered while using pgcopydb for Postgres to Timescale migration as well. The source would have plain Postgres table, but the same table on target will be partitioned using Postgres inheritance. |
I've seen this also, very rare but it happens. I'm having trouble reproducing it with my own smaller example however to share. |
I think you need to split the schema and data parts of the processing, and then tweak the schema on the target database to introduce partitioning, in order to repro. See https://pgcopydb.readthedocs.io/en/latest/tutorial.html#how-to-edit-the-schema-when-copying-a-database for details. Now if you can reproduce, the way to fix it might be to decide if we can use TRUNCATE or TRUNCATE ONLY by having a look at the TARGET schema to see if the table is partitioned there, whatever it might be on the source. At the moment we only have catalog entries for tables on the sourceDB, we need to grab them at the right point in time for the targetDB too now. |
@dimitri If I understand correctly, we should |
We have many cases to consider, but today only consider a few. The deal with TRUNCATE is how we use it in the same transaction as the COPY statement, in order to be able to use the COPY FREEZE option. In the case when either the table is not partitioned, or partitioned exactly the same way on the source and the target, that's fine. In any other case, we should disable this optimization. Here some details of the reasoning:
Then we might want to also have support for a change of partitioning scheme between source and target, including more partitioning levels (sub-partitions). In which case we want to route everything to the new parent table of course. And again, implement TRUNCATE on the parent table on the target, allowing Postgres to descend in the hierarchy. The simplest approach for now would consist of assuming we target the same partitioning schema on source and target when given a full clone command with |
I am also getting UPDATE: Side note: Probably documented somewhere, but learned you cannot have blank lines within any one of the ini filter sections. (Was adding blank lines for readability since the exclude list was lengthy). |
I am attempting to use pgcopydb to migrate data from our current schema to our new schema which uses citus. When executing
pgcopydb copy table-data --table-jobs 8 --index-jobs 2
errors are logged indicating thattruncate only
was called on the parent table for a partitioned table. Truncate only is only valid to execute on specific partitions but not the parent table.The text was updated successfully, but these errors were encountered: