Skip to Content
OpenETL

MySQL

Read MySQL and MariaDB tables in full, by a cursor column, or change by change from the binlog, and write into MySQL or MariaDB by appending, overwriting or merging.

The mysql package has a source and a destination, and both work against MariaDB too. The source reads the tables of one database: whole, from where a cursor column last got to, or as a stream of every insert, update and delete from the binary log (CDC). The destination writes each stream into a table of its own, and commits each epoch exactly once.

Source

What it reads

Each base table in the configured database is a stream, or only the ones tables lists. Views aren't offered, and a table's virtual generated columns are left out, since the binlog doesn't carry them.

A stream can be read three ways, which the pipeline picks with each stream's sync:

Sync modeOffered forHow it reads
full_refreshEvery tableThe whole table each time. A table whose primary key's columns are integers, decimals, strings, binary strings, dates, date-times, times, years or MariaDB UUIDs is read in key order, chunkRows rows a query, and a stopped read resumes after its last chunk. Another table is read in a single query.
incrementalTables with an integer, decimal, date, datetime, timestamp, year, char, varchar or text column, or MariaDB's inet4 or inet6The rows whose cursor column is at or above where the last read got to, up to the column's highest value when this read starts, in chunks ordered by the cursor, then the key.
cdcTables with a primary key read in chunks, as aboveFirst a snapshot of the table, in chunks of snapshotChunkRows, then every change from the binlog, which the source reads as a replica does.

An incremental read starts at the last read's highest cursor value, not after it, so the rows that had that value are read again. Rows whose cursor is NULL are never read, and deleted rows aren't seen: CDC is the mode that sees deletes.

A table read in key order whose key starts with an integer column other than year is read in up to 32 key ranges at once, between the column's least and greatest values, as many as the optimizer's estimate of its rows fills at chunkRows a range. A range that falls behind is divided again at the midpoint of what it has left. A read holds up to maxConnections connections, one for each lane it runs, and CDC holds one binlog connection besides.

A stopped full refresh or incremental read resumes in the order it started in. If the table's primary key was dropped or changed in between, a read that had got part of the way in key order fails with POSITION_LOST, and so does a key range that hadn't started yet, since its range is of the old key's first column: only a read from the start goes on from there. The same holds once a column of the key has been given another collation, which orders its text another way. A read again up to an earlier resume point (until) whose position, or its state's, is in another number of columns than the read orders by, as once its cursor moved into or out of the key, or its sync mode changed, fails with POSITION_LOST too. A table read in a single query that has been read is done, even if it has been given a key since.

How CDC hands over from the snapshot

Each chunk of a table's snapshot is read with a locking read (LOCK IN SHARE MODE), which waits for the transactions writing its rows to commit and holds back new writes to them until it has noted where the binlog ends. The chunk then holds exactly the changes before that position. The source holds the chunk until it has read the binlog up to it, emits it there, and emits the changes after it, so nothing is lost or repeated. Writes to the chunk's rows wait while it's read, as they would for any locking read; snapshotChunkRows bounds how many rows that is.

Transactions MySQL compresses in the binlog (binlog_transaction_compression) are read as any other. An XA transaction's changes are in the binlog from its XA PREPARE, and are read from there, before it commits. Its XA ROLLBACK then fails the read as lost (POSITION_LOST), as the destination has changes that never committed, also where a later read gets to it: a stream's state keeps the XA transactions it read prepared until their XA COMMIT. Resetting each table the transaction changed reads it again, without them, and brings the destination back in step. MariaDB and MySQL log XA COMMIT ... ONE PHASE as one transaction, which is read as any other. Every change carries a sequence number made of the read's epoch, which goes up each time a read continues on another server, the binlog file's number, the position its transaction starts at and its place in the transaction, so the destination applies a key's versions in order.

A transaction that changed a table that can't roll back, such as a MyISAM one, is in the binlog even where it rolled back, or rolled back to a savepoint, with the changes it undid to other tables, as MariaDB writes one rolled back to a savepoint with binlog_format = ROW, and one rolled back whole where a session set STATEMENT, or MIXED and made a temporary table. One that undid no change to a table the read has is passed. One that did fails the read as lost (POSITION_LOST), rather than send changes that never committed, and so does a later read that gets to it: resetting each table it names reads it again past the transaction. MySQL with enforce_gtid_consistency refuses a transaction that changes both kinds of table.

Set it up

The user in dsn needs SELECT on the tables it reads, and for CDC the privileges to read the binlog:

-- MySQL
GRANT SELECT ON app.* TO 'openetl'@'%';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'openetl'@'%';
-- MariaDB
GRANT SELECT ON app.* TO 'openetl'@'%';
GRANT REPLICATION SLAVE, BINLOG MONITOR ON *.* TO 'openetl'@'%';

REPLICATION SLAVE reads the binlog; REPLICATION CLIENT or BINLOG MONITOR reads where the binlog ends and which files it keeps. The snapshot's locking reads need only SELECT.

The server needs these settings, which a CDC read checks before it starts; it refuses to read otherwise, with an error naming what's set:

SettingValueNote
log_binONMySQL's default; MariaDB needs --log-bin
binlog_formatROW
binlog_row_imageFULLthe default
binlog_row_metadataFULLthe default is MINIMAL; FULL puts the columns' names in the binlog
binlog_row_value_optionsnot PARTIAL_JSONMySQL only

A session can set its own binlog_format, binlog_row_image or binlog_row_value_options. A change it logs as a statement, under STATEMENT or MIXED, has no rows to read; one that writes a table the read has fails the read rather than go unread. A multi-table UPDATE writes the tables its SET names, by name or alias, and may write any of its tables that has a column the SET names alone; a multi-table DELETE writes the tables it lists before FROM, or before USING. An UPDATE or DELETE after a WITH is checked the same way. A change it logs without a column the stream reads, other than a delete's or an old row's columns outside the key, or with a partial update of a JSON column, fails the read rather than set the column null. Either way the stream has to be read again.

The binlog connection presents a server ID, which must differ from every replica's: serverId, or else one derived from the pipeline's ID, at or above 2147483648. MariaDB ends a binlog connection when another connects with its server ID, as a replica can, or another pipeline whose ID derives the same one, and the read then fails as invalid config, naming serverId.

Warning

MySQL and MariaDB keep binlog files for binlog_expire_logs_seconds, whatever a pipeline has read. A pipeline that's paused or failing for longer finds its position purged: its read fails, and its tables have to be read again from a new snapshot. OpenETL reports how long the server keeps the file the pipeline's position is in, so it can warn before that happens, and a pipeline's preflight fails if the server keeps them for less than the time between its scheduled syncs.

Amazon RDS and Aurora keep binlog files for their binlog retention hours instead, which is unset by default, so the files go as soon as they can, whatever binlog_expire_logs_seconds says, and what OpenETL reports and checks from it doesn't hold there. Set it: CALL mysql.rds_set_configuration('binlog retention hours', 168);.

With GTIDs (gtid_mode = ON on MySQL; MariaDB always has them), a stream's state keeps the GTIDs it has read too, and after a failover to another server of the same replication topology the read continues from them on the new server. Without them, a read of another server fails as lost, and the check and a CDC pipeline's preflight warn.

Checks

A connection's check reports each of these items, with what it found, or why it failed and what to do about it:

ItemPasses when
net.dns, net.connectThe DSN's host resolves and takes a connection. Not for a Unix socket.
db.tlsTLS is on, in tls or the DSN: the server takes it, with a certificate the config trusts. Under preferred, a server without TLS warns.
db.connectThe user signs in, and the session takes the DSN's parameters: one that sets a variable the server doesn't have fails it.
database.foundThe database exists, and the user has a privilege in it.
tables.foundWith tables: each table it names is in the database.
tables.readThe user can select from each table the source offers, and the source can read each of their columns.
cdc.log-bin, cdc.binlog-format, cdc.binlog-row-image, cdc.binlog-row-metadata, cdc.binlog-row-value-optionsThe server's settings are as above.
cdc.gtid-modegtid_mode is ON, or the server is MariaDB.
cdc.replicationThe user has REPLICATION SLAVE, its own or through an active role, as SHOW GRANTS lists it.
cdc.binlog-monitorThe user can read where the binlog ends.
cdc.retentionAlways, saying how long the server keeps binlog files.

A check doesn't know which sync modes a pipeline uses, so the cdc items only warn there. A pipeline's preflight checks what it reads:

  • stream.NAME.read: the table is one the source offers, and the user can select from it.
  • stream.NAME.cursor, for an incremental stream: its cursor is a column of a type listed under What it reads.
  • stream.NAME.cdc, for a CDC stream: the table has a primary key the source reads in chunks.
  • With a CDC stream, the cdc items, which fail it but for cdc.gtid-mode. There cdc.retention fails if the server purges binlog files sooner than the pipeline's schedule goes between syncs.

Example

The config schema has every setting. This source offers the tables of app, and its pipeline reads orders by CDC and customers by its updated_at column:

apiVersion: openetl.io/v1alpha1
kind: Source
metadata:
  name: app-db
spec:
  connector: mysql
  config:
    dsn: { secret: app-db-dsn }
    database: app
---
apiVersion: openetl.io/v1alpha1
kind: Pipeline
metadata:
  name: app-db-to-warehouse
spec:
  schedule: { every: 1h }
  source:
    ref: app-db
    streams:
      - name: orders
        sync: cdc
      - name: customers
        sync: incremental
        cursor: updated_at
  destination: { ref: warehouse }

dsn is a DSN as the Go MySQL driver spells it, USER:PASSWORD@tcp(HOST:3306)/DATABASE, or a URL, mysql://USER:PASSWORD@HOST:3306/DATABASE or mariadb://…. It's a secret: store it with openetl secret set app-db-dsn.

The connector's sessions are in utf8mb4, in UTC, in the SQL mode STRICT_ALL_TABLES,NO_ENGINE_SUBSTITUTION, without a sql_select_limit, and with autocommit on, whatever the DSN or the server set: each connection sets them last. The DSN's collation is the sessions' if it's one of utf8mb4's, any the server has, and is left out otherwise, as its charset, time_zone, sql_mode and character set variables are. Each other parameter is one the driver takes, spelled as the driver spells it, such as parseTime, or else sets a session variable, such as wait_timeout=60 or @@session.wait_timeout=60. The connector refuses a DSN with one of the driver's parameters spelled in another case, or with one that sets no session variable, such as a global or a user variable. A connection whose DSN sets a variable the server doesn't have fails with CONFIG_INVALID.

allowPublicKeyRetrieval=true, which other MySQL clients take, is left out, and allowPublicKeyRetrieval=false is refused: without TLS, the connector always asks the server for its RSA public key when the server needs the password, as under caching_sha2_password or sha256_password. Anyone on the network path can then answer in the server's place. tls.mode verify-identity stops that, as it checks that the certificate names the DSN's host. verify-ca checks only the chain, so it takes another host's certificate that a trusted authority signed, and preferred and required check nothing.

TLS

Set tls to connect over TLS, for the source's queries and its binlog connection, and for the destination; without it, the DSN's tls parameter decides.

config:
  dsn: { secret: app-db-dsn }
  tls:
    mode: verify-identity
    ca: |
      -----BEGIN CERTIFICATE-----
      ...
modeConnects
disabledwithout TLS
preferredwith TLS if the server has it, without verifying its certificate
requiredwith TLS, without verifying the certificate
verify-cawith TLS, if the certificate is signed by ca
verify-identityas verify-ca, and if the certificate names the DSN's host; the default

ca holds the PEM certificates of the authorities that sign the server's certificate; without it, the system's are used. A user created REQUIRE X509 presents a client certificate, cert, and its key, key, which is a secret. MySQL generates a CA and certificates that name no host, so its own take verify-ca; MariaDB makes a certificate signed by itself, which verify-ca takes with that certificate as ca.

Types

A snapshot and the binlog read each value the same way.

MySQL or MariaDBArrives as
tinyint(1), bool, bit(1)boolean; as MySQL reads it, any value but 0 is true
tinyint, tinyint unsigned, smallint, year16-bit integer
smallint unsigned, mediumint, mediumint unsigned, int32-bit integer
int unsigned, bigint64-bit integer
bigint unsigneddecimal(20, 0)
float, double32- and 64-bit floats
decimal(p,s)a decimal of the same precision and scale up to a precision of 38; otherwise decimal(38, s) with s at most 9, and a value with more digits or places than that doesn't fit
char, varchar, the text types, enum, setstring, in UTF-8 from any character set; a set as its members joined by commas
binary, varbinary, the blob types, bit(n)binary; bit(n) as its bits in big-endian bytes
spatial typesbinary, as MySQL keeps them: a 4-byte SRID, then the geometry's WKB
datedate
datetimetimestamp in microseconds
timestamptimestamp in microseconds, in UTC
timetime of day in microseconds; a value below 0 or past 24:00:00, which time holds as a duration, doesn't fit
json, and MariaDB's json, which is longtext checked by json_validJSON, without the spaces MySQL prints
MariaDB's uuidUUID
MariaDB's inet4, inet6string, as MariaDB prints them

A value that doesn't fit is sent as MySQL prints it, with every digit, which OpenETL can't put in the declared type: by default its row is quarantined, as Holds and quarantine explains.

A zero date, 0000-00-00, or one with a zero month or day, which MySQL keeps where its SQL mode allows, arrives as null, so date, datetime and timestamp columns are listed as nullable even where NOT NULL. Other columns are listed as nullable unless they're NOT NULL.

Schema changes

A column added to a table read with CDC fails the read once, retryably, and the next attempt declares it. A column that was added and dropped again before the read reached it is left out. A column whose type changed so that the binlog's values no longer fit the type the read declared fails the read the same way. The binlog names columns as they were: a change from before a column was renamed, or added, that the read reaches after it, doesn't have it, and sends it as unchanged, so a merge keeps the value the destination has rather than setting it null. No change carries what the rename or the add did to existing rows, such as an added column's default: the destination has it once the row changes again, or a new snapshot of the table brings it. TRUNCATE isn't in the binlog as rows: the source logs a warning, and the destination keeps the rows; a new snapshot of the table brings it back in step.

A column whose type changed since the run discovered the table, so that it's declared as another type, fails the read retryably before it reads, in any mode, and the next attempt declares the new type; one declared as the same, as varchar(20) to varchar(40), reads on. That needs an OpenETL that gives a read the types the run declared.

Delivery

Full refresh and CDC streams replay exactly: a read resumed from a checkpoint yields the same rows in the same order. OpenETL counts incremental streams as ones that may repeat rows, because of the rows at the cursor's last value, and the destination's capabilities decide what guarantee that leaves.

A read OpenETL asks to end at an earlier resume point (until), to read a part again, sends nothing past it, then that resume point, and completes there. Where the stream's read completed in that part, as a scheduled pipeline's does, OpenETL asks the read to complete where it did (complete_at) instead: an incremental read goes up to the highest cursor value the first read went up to, rather than the column's highest now, and a CDC read stops at the binlog position the first read completed at, though the binlog has moved on; either then completes with the same state. A full refresh completes with no position, so a read again of a part it completed in goes to the table's end. A full refresh or incremental read sends the rows between the two ends again, as the table has them now. A CDC read from the same server sends the binlog's changes again as they were, with the same sequence numbers; the snapshot's rows of that part come as the table has them now, after those changes and before any later one, so a merged stream lands as it did, and an appended one has the rows as they are now. Those rows aren't held to the end, whether it's a resume point or a completion: they include rows written since the first read, past the end, and leave out rows deleted since, and if that leaves the read with fewer rows than the first read had, OpenETL fails the attempt with POSITION_LOST. From another server, by GTIDs, it sends the same changes with the new server's sequence numbers, which are above every one the first read sent, and the snapshot's rows after them. If that server hasn't every transaction the first read had read by that end, as where a failover lost some or a replica hasn't applied them yet, the read fails with POSITION_LOST rather than stop there without them.

Throughput

OpenETL 0.2.0-alpha, with the mysql and s3 packages built from this repository's main at commit e916cd72 rather than that release's packages, ran three full refreshes of one MySQL table, without TLS, into Parquet files on Amazon S3. Each run succeeded at its first attempt.

RunSync timeRows/sMB/sGB/hourCPU-seconds per GBJob peak memory
144.435 s855,102241.6869.625.954,092 MiB
243.637 s870,731246.0885.526.024,151 MiB
345.631 s832,688235.2846.825.873,990 MiB
Mean44.57 s852,840240.9867.325.954,151 MiB, the highest

The sync time is the sync's own record, its end time less its start time. It includes placing the job, starting the connectors and the engine, planning, reading, writing and every commit. The spread of the three times, the slowest less the fastest over the mean, is 4.5%. The rates are of the Postgres table that the MySQL table was copied from, its heap without indexes: 10,733,748,224 bytes and 37,996,289 rows. MySQL's copy holds 10,551,820,288 bytes (data_length). MB is 1,000,000 bytes and GB is 1,000,000,000 bytes. The CPU time and the peak memory are the job's, for the engine and both connectors, from the sync's record.

PartSet-up
DataOne InnoDB table of 16 columns and 37,996,289 rows, in utf8mb4, with no nulls: id bigint primary key, f1 and f2 bigint, f3 int, f4 and f5 double, f6 decimal(18,4), f7 tinyint(1), f10 and f11 date, f12 timestamp(6), and five text columns, f8, f9 and f13 to f15. Each text value is 32 characters of base64 cut from SHA-512 digests of the key, so it compresses poorly. The rows were copied from a Postgres table, where they take 267 bytes a row on average.
SourceMySQL 8.4.13 (mysql:8.4) with innodb_buffer_pool_size=20G. A full scan of the table read it into the buffer pool before each run. The source read on up to 8 connections, without TLS, as a user that signs in with caching_sha2_password, the server's default.
RunnerEC2 c8g.2xlarge in ap-southeast-2a: 8 vCPUs (Graviton4), 16 GiB, network up to 15 Gbit/s, and a 60 GB gp3 disk at 6,000 IOPS and 400 MB/s. It ran OpenETL's Compose stack from the release's compose.yml, with OPENETL_RESERVE=0,1Gi so that a job of 8 vCPUs fits. The job had 8 vCPUs, 13 GiB and 8 lanes.
Database machineEC2 c8g.4xlarge in the same zone: 16 vCPUs, 32 GiB, and a 300 GB gp3 disk at 16,000 IOPS and 1,000 MB/s. MySQL ran there alone, in Docker with host networking, on the private network.
BucketOne Amazon S3 bucket in ap-southeast-2. The s3 destination used the runner's instance role (OPENETL_CONNECTOR_AWS_CREDENTIALS=inherit). Each run wrote into a namespace of its own, with the destination's defaults: Parquet with zstd, and a fileSize of 256 MiB.
Packagesmysql and s3, built from this repository's main at commit e916cd72, not the packages of the release above. That release's CLI packaged them for linux/arm64 with openetl connector package, and openetl connector apply -f applied each package's descriptor.

Each run used these specs, with a pipeline and a namespace of its own. The source's DSN was USER:PASSWORD@tcp(HOST:3306)/data, with no parameters. The yearly schedule starts no sync during a run, so openetl sync started each one.

apiVersion: openetl.io/v1alpha1
kind: Source
metadata: { name: my-full }
spec:
  connector: mysql
  config: { dsn: { secret: mysql-dsn }, database: data, tables: [bench], maxConnections: 8, tls: { mode: disabled } }
---
apiVersion: openetl.io/v1alpha1
kind: Destination
metadata: { name: s3-out }
spec:
  connector: s3
  config: { url: s3://BUCKET/out, region: ap-southeast-2 }
---
apiVersion: openetl.io/v1alpha1
kind: Pipeline
metadata: { name: mysql-to-s3 }
spec:
  schedule: { cron: "0 0 1 1 *" }
  heal: { mode: "off" }
  resources: { size: { cpu: 8, memory: 13Gi } }
  source:
    ref: my-full
    streams:
      - { name: bench, sync: full_refresh }
  destination:
    ref: s3-out
    namespace: NAMESPACE

Before each timed sync, a sync of a one-row copy of the table, under the same stream name, wrote the destination's table first. The timed sync then replaced it, as overwrite is the default write mode for a full refresh. Delivery was exactly once. Commits were requested every 256 MB that the source read (delivery.commit.maxBytes), the default, and each sync made 8 to 11 commits. The time does not include making the data, the one-row sync, or reading the table into MySQL's buffer pool.

The runner's CPU limited the runs. The read, until 99% of the source's bytes had reached the runner, took 39.8 to 40.1 s. In it, the runner was 94 to 95% busy: destination-s3 used 3.3 to 3.4 cores and source-mysql 3.0. The runner's network received about 250 MB/s and sent about 200 MB/s. MySQL used about 0.9 cores and had room.

In each run, the runner's ENA driver counted 0.9 to 1.0 million packets over the outbound bandwidth allowance (bw_out_allowance_exceeded) and none over the inbound one. These counters do not show how much time that cost. The uploads were 99% done 39.8 to 40.9 s into the job, which ended 3.1 to 5.4 s later, with the last commit.

After each run, Amazon Athena queried a table defined over the files that the run's manifest lists. Its row count, its count of distinct ids, and its sums of f1, f6 and the lengths of f8 were equal to the source's in all three runs.

These numbers are for one case:

  • One row shape: 16 columns, with five random strings that compress poorly. Wider or narrower rows, other types and text that compresses change every number.
  • One machine size: a runner of 8 vCPUs and 16 GiB, with 8 lanes, whose CPU was the limit. A larger runner, or several workers (resources.workers), changes the numbers.
  • A cached source: MySQL read the table from its buffer pool. A source that reads from disk is slower.
  • Without TLS: the source's connections were plaintext, on a private network.
  • A full refresh of one stream into Parquet files. No incremental reads and no transforms.
  • MySQL in Docker on a neighboring EC2 machine, not a managed service, whose storage, network and CPU differ.
  • Three runs, one after another: the spread is that of three runs, not a distribution.

Limits

  • Nothing is held on the server for a pipeline, so there's nothing to acknowledge, set up or tear down: binlog retention is the server's (see above).
  • A table without a primary key, or whose key has a boolean (tinyint(1) or bit(1)), float, double, enum, set, bit, json or spatial column, can't be read with CDC, and is read whole in one query.
  • A vector column, or text in a character set without a decoder (such as dec8 or swe7), makes the table unreadable; the error names the column.

Destination

What it writes

Each stream becomes a table in the pipeline's destination.namespace, which is a database, or else in the config's database. If the pipeline's destination.tables gives the stream a name, the table has that name, exactly as written. Otherwise, the table has the stream's name as the pipeline's destination.naming gives it: by default, lowercase, with _ in place of anything outside a-z, 0-9 and _. Names are up to 64 characters. The database is created if it's missing.

Tables are InnoDB, in utf8mb4 with its binary collation (utf8mb4_0900_bin on MySQL, utf8mb4_nopad_bin on MariaDB), so keys that differ only in case, accents or trailing spaces stay apart.

All three write modes work:

  • Append inserts each epoch's rows.
  • Overwrite writes a read's rows to a table of its own, which replaces the target's rows when the read ends, so the target keeps its old rows until then.
  • Merge upserts each key's latest version, ordered by _openetl_seq, so an older version never overwrites a newer one. A column a version didn't send, which a source lists in _openetl_unchanged, takes its value from the key's latest earlier version in the epoch that sent it, unless the target's row is newer than that version, or else keeps the target's. Among an epoch's versions of a key, one without _openetl_seq ranks below one with it. Deletes are soft unless the pipeline sets destination.deletes: hard: the row stays, with _openetl_deleted true, and the values it had before the epoch, so an update in the delete's own epoch doesn't land; a key that's new in the epoch takes the delete's values. A hard delete leaves nothing of the row to order by, so a version older than the delete that comes in a later epoch puts the row back. Merge adds a unique index on the key's columns if the table has none; it fails, saying so, if the table has two rows with one key.

Each epoch is staged into tables of its own, one per stream and writer lane. MySQL commits before each DDL statement, so the destination makes every table, column and index an epoch needs first, then applies its rows in one transaction that only changes rows: it checks the fence row in _openetl_fence, applies each stream, and writes a marker per stream in _openetl_loads, all or nothing. A replaced attempt can't apply, and an epoch is never applied twice. Append and overwrite also skip rows a source sends again, by their _openetl_id, and merge keeps each key's latest version. So a stream lands exactly once, or effectively once when it's merged from a source that may repeat rows, unless the pipeline asks for less. Leave _openetl_fence and _openetl_loads in place.

A continuous pipeline commits every 10 seconds unless it sets its own delivery.commit.interval.

Set it up

The user in dsn needs CREATE, ALTER, DROP, SELECT, INSERT, UPDATE and DELETE on the database, for its tables, their staging tables, _openetl_fence and _openetl_loads, and CREATE on it, globally or by a pattern, if it doesn't exist yet. The destination adds indexes with ALTER TABLE, so it needs no INDEX.

GRANT CREATE, ALTER, DROP, SELECT, INSERT, UPDATE, DELETE ON raw.* TO 'openetl'@'%';

The check asks for all of these on the whole database, whatever the write mode: each write creates, indexes and drops staging tables in it, updates _openetl_fence, and deletes old markers from _openetl_loads. Grants on single tables don't count.

A connection's check has the source's net.dns, net.connect, db.tls and db.connect, and database.create: the user has those privileges on database, or, if it doesn't exist, may create it. The user's privileges are read from SHOW GRANTS, which lists those of its active roles too. A pipeline's preflight checks database.create on the database it writes to, and stream.NAME.write for each stream, which fails for a merged stream without a primary key.

Example

The config schema has every setting; tls is the source's, as TLS explains.

apiVersion: openetl.io/v1alpha1
kind: Destination
metadata:
  name: warehouse
spec:
  connector: mysql
  config:
    dsn: { secret: warehouse-dsn }
    database: raw

Types

Arrives asColumn
booleantinyint(1)
8-, 16-, 32- and 64-bit integerstinyint, smallint, int, bigint
unsigned integersthe same, unsigned
32- and 64-bit floatsfloat, double; NaN and infinities, which they don't hold, as null
decimal(p, s)decimal(p,s) up to MySQL's 65 digits and scale of 30; longtext past them
stringlongtext
binarylongblob
datedate
time of daytime(6); nanoseconds are cut to microseconds
timestampdatetime(6) in UTC, with or without a time zone, since timestamp ends in 2038; nanoseconds are cut to microseconds
UUIDchar(36)
JSON, intervals, lists, structs and mapsjson; on MariaDB longtext checked by json_valid

A key's string and binary columns are varchar and varbinary instead, sized together to fit InnoDB's index; a longer key value fails its epoch. A date or timestamp outside the years 1 to 9999 fails its epoch too.

Schema changes

New columns are added to the table, until it has the 1,017 columns InnoDB allows; past that, the destination refuses the column.

The destination doesn't change an existing column's type by itself, since ALTER TABLE … MODIFY can rebuild the table. When a stream's column widens, it refuses the change, the stream holds the column where it can, and the refusal gives the statement that makes the change, with the column's NOT NULL and default:

ALTER TABLE `raw`.`orders` MODIFY COLUMN `amount` decimal(20,2) NOT NULL DEFAULT '0.00'

Run it, then release the hold. Or let the destination make such changes itself with the pipeline's destination.typeChanges: allow, for every stream or one. It then widens integers to wider integers, an unsigned one to a wider signed one, float to double, integers to double and the small ones to float, integers and decimals to a decimal that holds them, a varchar or varbinary to a longer one, binary to longblob, and anything else to longtext. A change that isn't a widening is refused either way.

A schema change waits up to 5 seconds for its table's metadata lock, and tries up to 5 times in all, so queries on the table don't queue behind it.

Limits

A row too long for the server's max_allowed_packet can't be written: it fails the write with DATA_INVALID, naming the stream and the limit. Raise max_allowed_packet to write it.

A batch without columns fails the write, since a MySQL table has at least one.

Config

The config of a source or destination that names connector: mysql, from the package's source.schema.json and destination.schema.json.

Source

Prop

Type

Destination

Prop

Type

Releases

On this page