Search docs.molo17.com
    Configuration guide Pipelines

    Control how data lands on the target

    By default an entity makes the target a copy of the source: every insert, update and delete is applied, and a row that is already on the target is overwritten. Many targets need something else. An archive must keep the rows deleted on the source, a reporting table must not be overwritten by a colliding row, and a damaged part of a table must be reloaded without touching the rest. This guide builds an order archive that does all of that and checks every effect with SQL.

    In this guide

    You will learn how to create the target table from the source, leave deletes out of the operations an entity writes, choose what happens when an insert meets a row that is already on the target (Upsert, Skip or Fail), read the warning and the error each choice raises, and delete only some target rows before a snapshot reloads them.

    The steps were run on PostgreSQL 16 for both the source and the target.

    Quick information

    Goal

    Decide what an entity writes to the target, what it keeps there, and what it does with a row the target already holds

    Audience

    Data engineers who configure pipelines in the Control Plane

    Level

    Intermediate

    Time required

    About 30 minutes

    Area

    Control Plane → Pipelines → entity → Field mapping and Edit settings → Fine tuning

    Applies to

    Gluesync 2.3

    Before you begin

    Make sure that:

    1. A pipeline has a source and a relational target that Core Hub can read, and you can add and edit its entities. In this guide the pipeline is OrdersArchive, from PostgreSQL to PostgreSQL;

    2. The database user of the target can create tables, if you want Gluesync to create the target table;

    3. You can run SQL on the source and the target, in Query Studio or any SQL client;

    4. You try the deleting steps on a copy of the target first. A deletion on the target cannot be undone.

    Choose the right setting

    Each question has its own setting. You can combine them on one entity.

    What you need Setting In this guide

    The target table does not exist yet

    Create table "<name>" in Field mapping. See Target table creation.

    Create orders_history from orders.

    Rows deleted on the source must stay on the target

    Allowed operations in Fine tuning. See Allowed operations.

    Leave out Delete and Truncate.

    An insert meets a row that is already on the target

    On duplicate key in Fine tuning: Upsert, Skip or Fail. See On duplicate key.

    Use Skip, then try Fail.

    Part of the target must be reloaded

    Delete only some rows first when you start the entity. See Selective deletion ahead of snapshot.

    Reload the rows of one region.

    The whole target must match the source again

    Empty the table first when you start the entity

    Not needed. See Start a snapshot and CDC replication.

    Only some rows may reach the target

    Target filters

    Not needed. See Filter rows with a snapshot WHERE clause and target filters.

    Large volumes must load faster

    Bulk load settings in Fine tuning

    Not needed. See Tune replication throughput. Rows written in bulk do not use On duplicate key.

    Records must expire on the target

    TTL in the Entity section, on targets with native expiry

    Not needed. See TTL tagging.

    Guide steps

    Optional: create the demo source table

    SQL

    Skip this step if you use your own table. On the source, create an orders table with a few rows in three regions:

    CREATE TABLE public.orders (
      order_id    integer PRIMARY KEY,
      customer    varchar(60) NOT NULL,
      region      varchar(10) NOT NULL,
      status      varchar(20) NOT NULL,
      amount      numeric(12,2) NOT NULL,
      order_date  date NOT NULL
    );
    ALTER TABLE public.orders REPLICA IDENTITY FULL;
    
    INSERT INTO public.orders VALUES
     (1001,'Rossi Costruzioni','EU','shipped', 1250.00,'2026-10-02'),
     (1002,'Bianchi Srl','EU','shipped',  480.50,'2026-10-05'),
     (1003,'Acme Corp','US','open',     2300.00,'2026-10-11'),
     (1004,'Verdi Logistica','EU','open', 99.90,'2026-10-18'),
     (1005,'Globex','US','cancelled',    760.00,'2026-10-21'),
     (1006,'Initech','US','shipped',    1410.25,'2026-11-03'),
     (1007,'Neri Consulting','EU','open', 315.00,'2026-11-09'),
     (1008,'Umbrella Ltd','APAC','open', 5200.00,'2026-11-14');

    Do not create anything on the target: the next step creates the table.

    Create the target table from the source

    UI

    1. Open the pipeline, and select Entities +;

    2. In the Object browser, expand the schema and check the source table, here public and orders. The Field mapping dialog opens;

    3. Under Target, keep the Target Schema, here public. In Target Table, type the name of the new table, orders_history, and select Create table "orders_history".

    Field mapping dialog with orders_history tagged NEW in Target Table
    Figure 1. The new table is tagged NEW, and every source column gets a target column with the same name and type.
    1. Check the target types and lengths. Change a type in Target type if you need to;

    2. Select Confirm. The Create table orders_history dialog shows the statement Gluesync runs on the target;

    3. Select Create table orders_history.

    Create table orders_history dialog with the read-only CREATE TABLE statement
    Figure 2. The statement is read-only. Select Copy snippet to run it yourself instead, for example to add indexes or storage options.
    Expected result

    The table exists on the target as soon as you select Create table, before you save the entity. Its primary key comes from the source:

                        Table "public.orders_history"
       Column   |         Type          | Collation | Nullable | Default
    ------------+-----------------------+-----------+----------+---------
     order_id   | integer               |           | not null |
     customer   | character varying(60) |           |          |
     region     | character varying(10) |           |          |
     status     | character varying(20) |           |          |
     amount     | numeric(12,2)         |           |          |
     order_date | date                  |           |          |
    Indexes:
        "orders_history_pkey" PRIMARY KEY, btree (order_id)

    To change the statement, copy it, run your own version on the target, then select the table in Target Table. The statement leaves out foreign keys. See Target table creation.

    Keep the rows deleted on the source

    UI

    1. In Selected entities, select Entity settings (the gear icon) on the row of the entity;

    2. Select Fine tuning;

    3. Open Allowed operations and clear Delete and Truncate. Keep Insert and Update.

    Expected result

    The counter of Allowed operations shows 2. Deletes and truncates captured on the source will be dropped by the target.

    Allowed operations also applies to the snapshot. A Keep and merge snapshot writes updates, and an Empty the table first or Delete only some rows first snapshot writes inserts: keep both Insert and Update. It does not stop the deletion that Empty the table first and Delete only some rows first run before the copy. See the last step.

    Choose what happens on a duplicate key

    UI

    1. In the same Fine tuning section, open On duplicate key and select Skip.

    Fine tuning section of the entity settings with the Allowed operations list showing Delete and Truncate cleared and Insert and Update selected
    Figure 3. Allowed operations keeps Insert and Update. On duplicate key is set to Skip.

    The three choices:

    Choice When an insert meets a row with the same key

    Upsert (default)

    The target row is overwritten with the incoming one.

    Skip

    The target row is kept, the incoming row is discarded, and a warning lists its key. Replication continues.

    Fail

    The entity stops with an error and nothing more is written until you act.

    1. Close the dialog and select Confirm and continue.

    Start the entity

    UI

    1. Open the entity and select Start;

    2. In Start from, keep Full copy. In Data already in the target, keep Keep and merge;

    3. Select Start entity.

    Expected result

    The entity is Active and the target has the 8 source rows:

    SELECT order_id, customer, region, status, amount FROM orders_history ORDER BY order_id;
    Check that deleted rows stay on the target

    SQL

    1. On the source, insert an order, update one and delete one:

      INSERT INTO orders VALUES (1009,'Stark Industries','US','open',8800.00,'2026-11-20');
      UPDATE orders SET status = 'shipped' WHERE order_id = 1003;
      DELETE FROM orders WHERE order_id = 1005;
    2. After a few seconds, read the target:

      SELECT order_id, customer, region, status, amount FROM orders_history ORDER BY order_id;
    Expected result

    Order 1009 is on the target and order 1003 is shipped. Order 1005 is still there, although the source deleted it:

     order_id |     customer      | region |  status   | amount
    ----------+-------------------+--------+-----------+---------
         1001 | Rossi Costruzioni | EU     | shipped   | 1250.00
         1002 | Bianchi Srl       | EU     | shipped   |  480.50
         1003 | Acme Corp         | US     | shipped   | 2300.00
         1004 | Verdi Logistica   | EU     | open      |   99.90
         1005 | Globex            | US     | cancelled |  760.00
         1006 | Initech           | US     | shipped   | 1410.25
         1007 | Neri Consulting   | EU     | open      |  315.00
         1008 | Umbrella Ltd      | APAC   | open      | 5200.00
         1009 | Stark Industries  | US     | open      | 8800.00
    See a duplicate key skipped

    UI + SQL

    An archive that keeps deleted rows meets a duplicate key as soon as the source reuses a key.

    1. On the source, insert a new order with the key of the deleted one:

      INSERT INTO orders VALUES (1005,'Hooli','US','open',640.00,'2026-11-25');
    2. On the target, read order 1005:

      SELECT order_id, customer, status, amount FROM orders_history WHERE order_id = 1005;
    3. In the Control Plane, select Notifications, then the warning Duplicate rows skipped on public.orders → public.orders_history.

    Notifications hub with the expanded warning Duplicate rows skipped on public.orders → public.orders_history and the message 1 duplicate row(s) skipped with keys order_id=1005
    Figure 4. The warning in the Notifications hub lists the key of each skipped row.
    Expected result

    The target still holds the archived order, Globex, cancelled. The entity stays Active, and the warning reads:

    1 duplicate row(s) skipped. Skipped rows (batch index and key values): [#0 transactionId=... keys={order_id=1005}]

    Skip acts on inserts only. A later update of the new source row is applied to the target row with the same key. In the test, UPDATE orders SET status = 'shipped' WHERE order_id = 1005 replaced the archived Globex row with Hooli, shipped. If an archive must never be overwritten, also clear Update, or give the target a key that the source cannot reuse.

    Optional: stop on a duplicate key with Fail

    UI + SQL

    Use Fail when no data may move past a collision until someone looks at it.

    1. On the pipeline page, open Options (the three-dot icon) on the row of the entity and select Edit settings;

    2. Select Fine tuning, set On duplicate key to Fail, close the dialog and select Confirm and continue. The entity stays Active;

    3. On the source, delete an order, then insert it again with other values, and add one more order:

      DELETE FROM orders WHERE order_id = 1006;
      INSERT INTO orders VALUES (1006,'Wayne Enterprises','US','open',990.00,'2026-11-26');
      INSERT INTO orders VALUES (1010,'Soylent','EU','open',150.00,'2026-11-26');
    Data pipelines page with the entity in Error
    Figure 5. With Fail, the duplicate key stops the entity and raises a Batch Update error.
    Expected result

    The entity is in Error. The target keeps the archived order 1006 (Initech), and order 1010 is not written: nothing after the collision is applied. The error in the Notifications hub reads:

    Batch entry 0 INSERT INTO "public"."orders_history" (...) VALUES (('1006'::int4), ('Wayne Enterprises'), ...)
    was aborted: ERROR: duplicate key value violates unique constraint "orders_history_pkey"
      Detail: Key (order_id)=(1006) already exists.
    1. To let the data move again, decide what to do with the target row, then set On duplicate key back to Skip (or Upsert) in Edit settings and select Confirm and continue.

    Expected result

    The entity is Active again and continues from where it stopped. A Duplicate rows skipped warning names order_id=1006, the target keeps Initech, and order 1010 is now on the target.

    Restarting with Fail still set replays the same change and stops again, as long as the row is on the target. See Fail: what stopping means.

    Reload part of the target before a snapshot

    UI + SQL

    Suppose the rows of one region were damaged on the target. You can delete just those rows and copy them again, without emptying the table.

    1. To have something to repair, damage the EU rows on the target, and delete one EU order on the source:

      -- on the target
      UPDATE orders_history SET amount = 0 WHERE region = 'EU';
      -- on the source
      DELETE FROM orders WHERE order_id = 1002;
    2. Open the entity and select Pause, then Pause entity;

    3. Select Start. In Start from, select Full copy. In Data already in the target, select Delete only some rows first;

    4. Under Delete the rows where, set the condition: region, is equal to, EU;

    5. Select I understand that rows in the target will be deleted.

    Sync changes dialog with Full copy and Delete only some rows first selected
    Figure 6. The sentence under the condition says what will be deleted. What will happen lists the deletion first, then the copy and the live changes.
    1. Select Start entity;

    2. Read the target:

      SELECT order_id, customer, region, status, amount FROM orders_history ORDER BY order_id;
    Expected result

    The EU rows have their source amounts again, and order 1002, deleted on the source, is gone from the target:

     order_id |     customer      | region | status  | amount
    ----------+-------------------+--------+---------+---------
         1001 | Rossi Costruzioni | EU     | shipped | 1250.00
         1003 | Acme Corp         | US     | shipped | 2300.00
         1004 | Verdi Logistica   | EU     | open    |   99.90
         1005 | Hooli             | US     | shipped |  640.00
         1006 | Initech           | US     | shipped | 1410.25
         1007 | Neri Consulting   | EU     | open    |  315.00
         1008 | Umbrella Ltd      | APAC   | open    | 5200.00
         1009 | Stark Industries  | US     | open    | 8800.00
         1010 | Soylent           | EU     | open    |  150.00

    The rows outside the condition were not deleted, so the copy met them as duplicates. With Skip, they kept their target values, and two Duplicate rows skipped warnings list 1003, 1005, 1006, 1008 and 1009.

    • The deletion runs even when Delete is not in Allowed operations. On an archive, it removes rows the source no longer has, as it did with order 1002. Keep the condition to the rows you can copy again.

    • The copy writes inserts, so the rows you keep follow On duplicate key: Skip keeps them as they are, Upsert overwrites them with the source values, and Fail stops the entity on the first one.

    The condition is saved on the entity, in Edit settings → Target → Selective deletion ahead of snapshot. It runs only when a snapshot starts with Delete only some rows first: in the test, a later Keep and merge snapshot deleted nothing.

    Verify the result

    You control how data lands on the target if:

    • the target table was created from the source, with its primary key;

    • a row deleted on the source stays on the target;

    • an insert with a key the target already holds is skipped and named in a Duplicate rows skipped warning;

    • with Fail, the same collision stops the entity, and switching back to Skip lets it continue;

    • a snapshot with Delete only some rows first deletes and copies again only the rows of the condition.

    Troubleshooting

    Problem Possible cause What to do

    Batch Update: duplicate key value violates unique constraint, and the entity is in Error

    On duplicate key is Fail, and an insert met a row with the same key

    Decide what to keep, then set On duplicate key to Skip or Upsert in Edit settings, or delete the target row and start the entity again

    Duplicate rows skipped on <entity> warnings

    On duplicate key is Skip, and inserts met rows with the same key. A snapshot with Delete only some rows first raises them for every row it did not delete

    Nothing to do if that is what you want. Compare the listed keys with the source to reconcile them

    A row deleted on the source is still on the target

    Delete is not in Allowed operations

    Expected for an archive. Select Delete again if the target must match the source

    An archived row was overwritten by new values

    The source reused the key and then updated the new row. Skip acts on inserts only

    Also clear Update in Allowed operations, or use a target key the source cannot reuse

    Archived rows disappeared after a snapshot

    The snapshot started with Empty the table first or Delete only some rows first. Allowed operations does not stop that deletion

    Use Keep and merge on an archive, or narrow the condition to rows the source still has

    Start entity is disabled with Delete only some rows first

    The confirmation box is not selected, or a condition has no value

    Select I understand that rows in the target will be deleted and complete the condition

    Snapshot is not on the entity page

    The entity is Active

    Select Pause, then Start with Full copy

    Nothing is written to the target

    Insert or Update is missing from Allowed operations, and the snapshot or the live changes use it

    Select Insert and Update again