Search docs.molo17.com

    CedarDB glyph CedarDB agent

    Target CedarDB

    CedarDB speaks the PostgreSQL 16 wire protocol, so this agent is the PostgreSQL target with CedarDB’s connection defaults and with the parts of the PostgreSQL write path that CedarDB changes. The JDBC driver is the PostgreSQL one, and there is no separate SQL dialect.

    The agent is target only: CedarDB has no logical replication, replication slots or triggers yet, so change capture from CedarDB is not available.

    Prerequisites

    To have Gluesync writing into your CedarDB instance you will need:

    • A CedarDB server, Community or Enterprise edition. The Community edition is limited to 64 GiB and becomes read-only once the database exceeds it;

    • A user with permission to read and write the target tables and, for bulk operations, to create the staging tables;

    • Network access from Core Hub to the server, on port 5432 by default.

    Setup via Web UI

    • Hostname / IP Address: DNS record or IP address of the CedarDB server;

    • Port: Optional, defaults to 5432;

    • Database name: Defaults to postgres;

    • Username: Defaults to postgres;

    • Password: Password belonging to the given username;

    • Enable TLS: off by default. See TLS;

    • Trust server certificate: see TLS.

    Specific configuration

    The settings of the PostgreSQL target apply, see PostgreSQL target advanced settings.

    Enable Recursion Protection is not offered, and it is off whatever a copied configuration says: it needs replication origins, which CedarDB does not have.

    TLS

    CedarDB creates a self-signed certificate at its first start and also accepts plain connections, so TLS is off by default. The JDBC sslmode follows the two TLS fields:

    Enable TLS Trust server certificate JDBC sslmode

    Off

    Not used

    disable

    On

    On

    require: the connection is encrypted and the certificate is not checked against a CA

    On

    Off

    verify-full: the certificate must be signed by a trusted CA and match the host name

    With TLS off the agent sets sslmode to disable explicitly, so the driver does not negotiate TLS. A CedarDB server with its self-signed certificate needs Trust server certificate on, or a trust store that holds its certificate.

    Server check

    When the connection is checked, the agent runs SELECT version() and the answer must name CedarDB. Any other server, including a plain PostgreSQL, fails the check with a message that names the server that answered:

    This target needs CedarDB; the server reports 'PostgreSQL 16...'

    The agent logs the CedarDB version once.

    Connections

    CedarDB accepts at most 100 connections. Set the Max connections count of the connection (maxConnectionsCount) so that all pipelines that write to the same CedarDB server stay below that limit, with room left for your own clients.

    Write modes

    Batch

    The default. The agent uses the PostgreSQL statements: INSERT, INSERT …​ ON CONFLICT DO UPDATE (an upsert by key) and DELETE. CedarDB has no MERGE, and the agent does not need it.

    A decimal is bound as text and cast to the precision and scale of the column, so every digit is stored.

    Bulk

    Bulk operations are set per entity with Use bulk operations during Snapshot (useBulkOperationsWhileSnapshot) and Use bulk operations during CDC (useBulkOperationsDuringCDC), see Write strategies and Bulk load.

    Snapshot

    Each flush is one transaction with one COPY straight into the target table. There is no staging table and no second pass. The COPY is binary, except for the columns CedarDB does not read in binary (tinyint, vector and a numeric that needs 38 digits), which use the text format. A snapshot of an entity without a key takes the same direct COPY.

    If the target already holds a key that the flush writes (for example a snapshot over existing rows), the COPY is rolled back and the entity is loaded through the staging merge below, which replaces rows by key until the snapshot ends. The agent logs that once per entity.

    Change capture

    Changes are written to a staging table and merged into the target table, in one transaction per flush.

    When Use bulk operations during CDC (useBulkOperationsDuringCDC) is on for an entity, the agent does not apply an update as an UPDATE statement. It loads the change into a staging table, deletes the existing row from the target table and inserts the new version of it. With the option off, updates are applied as UPDATE statements.

    For the target table this has the following effects:

    • Anything that reads the change log of the target database sees a DELETE and an INSERT instead of an UPDATE;

    • Columns that Gluesync does not write, such as a column with a default value, are set again as for a new row.

    Entities whose target table has an identity (auto-increment) column ignore the option: their updates are always applied as UPDATE statements.

    An entity with an enum column that also needs a text COPY (a tinyint, vector, inet, bit string, range, wide numeric or array column next to it) is not bulk loaded. The batch statements write it, because a text COPY into a table with an enum column stops the CedarDB server.

    Each bulk flush logs one INFO line with the entity, the path (direct-copy or staging-merge), rows, bytes, the time of the COPY and of the merge, rows per second and MB per second.

    Retry on write conflicts

    CedarDB never waits for a row that another transaction is writing: it fails at once with SQLSTATE 40001. The agent runs every write transaction, batch or bulk, again in a fresh transaction, for up to 6 attempts. The delay starts at 50 ms, doubles after each attempt, includes jitter and is capped at 2 seconds. If the last attempt fails, the error is reported with the attempt count. Writes are idempotent (upsert by key, delete by key, staging merge), so a retry does not duplicate rows. Other errors are not retried by the agent.

    A staging merge that follows earlier snapshot flushes whose rows are still in the staging table is not repeated inside the agent, because the staging table is emptied when a merge fails. The failure is reported and the snapshot resumes from its last confirmed position.

    Performance

    The direct snapshot COPY is about twice as fast as staging the rows and merging them. The benchmark loads one million rows (a bigint key, int, double, a 40-character varchar, timestamp and numeric(18,4), about 91 MB as COPY text) as the snapshot of an entity with a key. Median of three runs on an Apple M5 Max with a Docker VM of 18 vCPU and 23 GiB, with Gluesync and CedarDB on the same host:

    Path Flush Rows/s MB/s

    Staging and merge

    10,000 rows

    361,934

    32.9

    Direct COPY

    10,000 rows

    764,742

    69.5

    Staging and merge

    One flush of 1M rows

    231,309

    21.0

    Direct COPY

    One flush of 1M rows

    388,878

    35.3

    The flush of 10,000 rows is the most a source hands over per iteration by default. The rates include the agent’s own work (building the rows and the binary encoding) and move with the load of the host. In a real pipeline the throughput is usually bound by the source, not by the target.

    Tables created by the agent

    Gluesync can create the target tables, as it does for any SQL target (see Target table creation). The tables are the PostgreSQL ones, except for the types CedarDB lacks or limits:

    • numeric and decimal: CedarDB holds 38 digits at most. A type that fits is kept as numeric(p, s). A numeric without precision becomes numeric(38, s) with its declared scale, or numeric(38, 10) when it has none, because the bare numeric of CedarDB is numeric(38, 6) and rejects a value with more fractional digits. A negative scale or a scale above the precision is widened so every source value fits (NUMBER(5,-2) becomes numeric(7,0), NUMBER(5,9) becomes numeric(9,9)). A type that needs more than 38 digits, such as numeric(60,45) or numeric(40,2), becomes text holding the plain digits of each value, never rounded, with a warning that names the column and its declared type. A value with more fractional digits than its numeric column is rounded half up, and the first rounding of a column that drops a non-zero digit is logged as a warning;

    • time with time zone (timetz) becomes text, written as ISO-8601 HH:mm:ss[.SSSSSS]±hh:mm;

    • any other type CedarDB does not have (xml, cidr, macaddr, macaddr8, hstore, multiranges, money, geometric types, text search types, pg_snapshot, txid_snapshot, pg_lsn and the PostGIS types) becomes text, with a warning.

    Data types

    The type matrix lists the types CedarDB has. These are the Gluesync types and the CedarDB types the agent writes:

    Gluesync type Default Supported

    SHORT

    smallint

    smallint, smallserial, tinyint

    INT

    integer

    integer, int, serial

    LONG

    bigint

    bigint, bigserial, oid

    BOOLEAN

    boolean

    boolean, bool

    BIG_DECIMAL

    decimal

    decimal, numeric

    FLOAT

    real

    real

    DOUBLE

    double precision

    double precision, float

    LOCAL_DATE

    date

    date

    LOCAL_TIME

    time without time zone

    time, time without time zone

    LOCAL_DATE_TIME

    timestamp without time zone

    timestamp without time zone, timestamp

    OFFSET_DATE_TIME

    timestamp with time zone

    timestamp with time zone, timestamptz

    STRING

    varchar

    varchar, char, character, character varying, text, json, jsonb, inet, uuid, interval, int4range, int8range, tsrange, tstzrange, daterange, bit, bit varying, enum, vector

    BYTE_ARRAY

    bytea

    bytea

    ARRAY

    array

    array

    Limitations

    • numeric and decimal have a precision of at most 38 digits (a wider type is created as text, see Tables created by the agent), and NaN is not accepted for them;

    • date and timestamp values cannot be infinity or -infinity;

    • CedarDB canonicalises tsrange and tstzrange values to [lower, upper). A range written as (a,b] is read back as the equivalent range at microsecond precision. numrange is not supported: CedarDB changes its bounds, so the values would not be the same;

    • An enum column that needs a text COPY is written in batch, see Write modes;

    • With bulk operations, an array of numeric(p,s) cannot be part of a key, because CedarDB does not compare it with the staging array. Arrays of the other types, with NULL elements, are matched;

    • A timestamptz is shown in the time zone of the session that reads it;

    • Recursion protection is not available;

    • CedarDB accepts at most 100 connections, see Connections;

    • CedarDB is not available as a source.

    Setup via Rest APIs

    Here following an example of calling the Core Hub’s Rest API via curl to setup the connection for this Agent.

    Connect the agent

    curl --location --request PUT 'http://core-hub-ip-address/pipelines/{pipelineId}/agents/{agentId}/config/credentials' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: ••••••' \
    --data '{
            "hostCredentials": {
            "connectionName": "myAgentNickName",
            "host": "cedardb-host",
            "port": 5432,
            "databaseName": "postgres",
            "username": "postgres",
            "password": "",
            "maxConnectionsCount": 50,
            "enableTls": false,
            "trustServerCertificate": false
          }
    }'