Staging Cluster

Support Status Test Case
Production 1
Version 3.0.13

A staging cluster is a child cluster of a production cluster containing 3 nodes, one replica is detached from replication and proxies track the the status of the standalone node to enable dev team to test on production data

Creating a staging or a child cluster (since 3.1.44)

A staging cluster and a child cluster of a cluster are created in one call, on the same replication-manager as the parent, on OpenSVC or Kubernetes:

  • Dashboard: cluster menu Provision > New Staging Cluster or New Child Cluster. The plan is shown first, or why it is refused.
  • API: POST /api/clusters/{parent}/actions/create-staging or create-child, body {"name", "dbImage", "dbCount", "confirm"}; confirm false returns the plan.
  • MCP: cluster-create-staging, cluster-create-child.
Staging Child
Use the dev team tests on production data test a migration (another release) under the parent's real writes
Default name <parent>-staging <parent>-child
Databases 3 2
Own replication-source-name staging child
After the seed one replica detached: 1 Master, 1 Slave, 1 StandAlone, the proxy tracking the StandAlone every node keeps replicating

What the creation does:

  1. Checks the parent first: it must hold a logical backup (mysqldump or mydumper) on its backup server. Without it nothing is created: take a logical backup of the parent first.
  2. Creates the cluster with the parent's orchestrator, database image (unless another release is given), DBU per node, proxy type and proxy credential, logical backup tool, and the parent's monitoring and replication accounts (same name, same password), the parent as multisource head cluster. Since 3.1.45:
    • its GTID domain is the CRC32 of its own name, like any cluster (it was the parent's
      • 1: every child of a parent shared one domain). A plan whose domain is the parent's is refused: choose another name;
    • its databases are sized from the DBU before they are provisioned (1 DBU = 1 core, 4 GB, 20 GB, 1000 IOPS): 2 DBU per node give 2 cores, 8 GB, 40 GB and 2000 IOPS, so innodb_io_capacity_max 2000 (it kept the defaults, 300 IOPS, whatever the DBU).
  3. Bootstraps a regular master-slave under its own replication-source-name (staging or child).
  4. Restores the parent's backup on its master, data only: the system tables of its own release are kept, no account is loaded from the parent. Its replicas receive the restore through replication (see The restore on the master). Its master then replicates from the parent's master under the parent's replication-source-name, the same name on both sides: the two names must differ. Its position combines the backup's position in the parent's domain with its own current position in its own domain.
  5. For a staging cluster, detaches one replica as the staging server, once that replica has applied all the master wrote (see below).

The progress is the state CINF0014 on the new cluster; WARN0239 tells the step where it stopped and why. A cluster whose creation stopped is kept: fix the cause and reseed it from its parent, or drop it.

Rights: cluster-staging (staging) or cluster-replication (child) on the parent, and the right to create a cluster.

The indexes of a child (since 4.0.1)

Each index of a MariaDB child is filled and kept up to date by a process of its own: its own reader of the parent's binlog, its own position, its own initial load. A slow or failing index never delays another one, and the indexes load in parallel. The cost is one binlog reader on the parent per index.

An index is not replicated, a copy is

  • An index (index mode: a query, the denormalized table) is a stream written into one server, never replicated: its rows are written with sql_log_bin=0, so they never reach the child's binary logs nor its replicas. Each server that keeps the index does so through its own link, with its own reader and its own position. The link's account on the child needs SUPER or BINLOG ADMIN (to set sql_log_bin).
  • A copy (table or full mode: the source's tables as they are, the rules of a child, a PostgreSQL source copied into MariaDB) is written with the binary log on: the child's replicas follow it by their own replication. Into PostgreSQL, the copy is written to the WAL as any write, and the standbys follow it.
  • A link carries one of the two, never both: a hand-written link that mixes a copy and an index is refused at its start, with the reason. replication-manager writes each index its own link.
  • A DuckDB index is always written out of the binary log (the engine refuses row events): its child has one server.

Each index has its own merge interval (the index settings, Merge interval, 0 to 86400 seconds): 0 applies each change at once; more collects the changes in a staging table merged into the index every this many seconds. The merge interval concerns the engines with a consolidated apply: ColumnStore and DuckDB (the changed keys deleted, then the rows bulk-loaded) and S3 (consolidated by partition: the partition touched rebuilt and swapped in); their deletes scan the table, so they cost far less merged hourly (3600) while the other indexes stay live. A row engine (InnoDB, Aria, TidesDB, RocksDB) applies the changes as they come. Left empty, an index takes the child's Merge Interval, the default of its indexes. The child's dashboard shows, for each index, its merge interval, its last and next merge, and what is waiting.

Reloading an index: versions (since 4.0.1)

Every build of an index (its first load, a Reload index, the reseed of its child) loads a new version of its table beside the one that serves. The live index keeps answering queries and keeps receiving the changes of its source during the whole reload; once the new version has caught up with the live one, it is switched in by one RENAME TABLE (all the tables of the index at once), and the old version is dropped after the next change applied. A failed or interrupted reload drops its new version and starts again; the live version is never touched.

  • Double disk during a reload. The new version is a full second copy of the index beside the live one until the switch. Before a build starts, replication-manager checks the free space of the child's data directory; when it is short, the build waits and the child shows WARN0378 (the version build of the index waits for free space, with the space needed and the space free). The warning clears, and the build starts, as soon as there is room. The free space comes from the server (information_schema.DISKS), else from the database jobs' report of the data directory; when neither tells, a table over 1 GB is not doubled blind: the build waits with WARN0378 saying so.
  • Reload engine (index setting shadow-reload-engine, beside target-engine): empty, the new version is loaded directly in the index's target engine; set (for example InnoDB), it is loaded in that engine, which takes concurrent writes, and each partition is moved to the target engine (ALTER TABLE ... ENGINE=) before the switch.
  • Off-switch: replication-plugin-reload-shadow = false reloads in place, as before versions: the table is emptied, then filled again, and does not answer completely meanwhile.

The child's dashboard shows, for each index, its versions (the current one, the one being built with its progress, the previous one kept for a rollback), the wait for space, and the last version dropped or aborted with its reason.

  • Tables gone from the child: when the child lost the index's tables (it was reprovisioned), Reload index builds the index from scratch (its position and its work tables reset, its definition kept), as a removal and a new put of the index would; replication-manager logs which tables were missing.

Primary-key order of an InnoDB index: replication-plugin-load-pk-order

A table whose pages are out of primary-key order on disk is slow to scan from disk: InnoDB reads its pages one by one, without read-ahead (measured: 16.2 s for a cold scan of a 7.4-million-row partition, 2.85 s once the partition was rebuilt). A build therefore loads each partition in primary-key order: the source is read range by range in the order of the index's driving key, whatever the plan of its join, and each partition's table has one writer at a time, its rows written in that order (the build's writers work on different partitions). This costs nothing on the build's time: on a 24-million-row test index the build took the same time, and a cold scan of a partition went from 0.78 s to 0.43 s.

  • replication-plugin-load-pk-order (default true, GUI Analytic Child, Load In Primary Key Order): false lets several writers load one partition at once, as before.
  • replication-plugin-load-pk-rebuild (default false, GUI Rebuild In Primary Key Order): also rebuilds each InnoDB partition table (ALTER TABLE ... FORCE, replication-plugin-threads at once) before it joins the version, for a fully compact table. It writes the whole version a second time: on slow disks it took longer than the load itself. The index status shows its time under pk order rebuild. Other engines are never rebuilt (RocksDB keeps its rows in key order itself, an Aria or S3 table is read in file order, ColumnStore and DuckDB are columnar).

Load concurrency: replication-plugin-threads-max

A reload is loaded by several writers at once, and the stream between the parent and the child is uploaded by several uploads at once. Both counts tune themselves: they start at replication-plugin-threads (default 2), rise while the rows applied per second (the reader) or the bytes uploaded per second (the publisher) keep rising, and step back when they stop rising. replication-plugin-threads-max caps both (default 0: four times replication-plugin-threads, at most 64); 1 switches the publisher's concurrent uploads off (one upload at a time, as before). The dashboard shows both current values under In flight.

Compression of S3 tables: replication-plugin-s3-compression

Every table the CDC moves to the S3 engine is compressed: replication-plugin-s3-compression (default zlib) is the COMPRESSION_ALGORITHM of those tables; none stores them uncompressed. It applies to the tables moved from then on; a table already in S3 keeps its compression.

Reading the source: parallel readers, one streamed SELECT, the range step

A build reads its source on one consistent snapshot (REPEATABLE READ for its own sessions, whatever the server's default), at one GTID, the source only read.

  • Parallel readers. With replication-plugin-threads above 1, the source is read by that many sessions at once (at most 16), all opened on one point of the binary log: replication-manager's source user runs BACKUP STAGE START and BACKUP STAGE BLOCK_COMMIT (the source's commits wait for a few milliseconds, never more than 5 seconds whatever happens), opens every reader's snapshot, reads the GTID and ends the stage. This needs the BACKUP privilege (MariaDB 10.5 and later; RELOAD before). The work is split by ranges of the driving table's primary key, each range read whole by one reader.
  • One streamed SELECT. Without the privilege (the index status says so under Source readers, with the grant to give), with a MySQL source, or with replication-plugin-threads 1, one session reads the source: the build is then one SELECT, its rows read continuously, never paused, cut into parts on the disk of replication-manager (the spool) while they wait for their upload. On a 24-million-row test index this read 356,000 rows/s, against 193,000 by ranges.
  • Spool limit: replication-plugin-spool-max-gb (default 64, GUI Spool Max (GB)): the most the spool may hold. Past it, or when its filesystem falls under 10% free (at least 2 GB), the build stops with the reason in the index status (its version abandoned, the index serving as before) and is tried again later. 0 reads that single session by ranges instead, pausing between them: no spool.
  • Range step (index setting range-step, default 10000 rows): the width of a range read by a parallel reader. An integer primary key is cut by arithmetic from its smallest and largest values (no extra read); another key by a probe of the step's last key.

Part size: replication-plugin-restore-batch-gb

A build is sent in parts cut by their size, not by a number of rows (a narrow row and a JSON document differ a hundred times): replication-plugin-restore-batch-gb (default 1, 0.01 to 4, GUI Init Part Size (GB)). Parts are spooled to disk on both sides, never held in memory; a reader loads at most 4 GB of parts at once. A seed's restore checkpoint takes it up to 256 MB.

Reload required

A build is never resumed: a stop of the child's plugin during a build (a restart, a crash) drops the partial version, and the index shows reload required with the reason until a new version of its table starts (by itself when its stream is rebuilt, else with Reload index). The live version keeps serving meanwhile.

Several indexes into one table: slices (since 4.0.1)

Two or more indexes (two sources, or one query split) can fill one table: each index gets a slice (index setting Slice, 1 to 65535, unique for that table, kept). The index fills its own table <table>_s<slice>, its rows carrying cdc_source = its slice, with its own stream, position and versions: reloading one slice never touches the others. replication-manager makes the table the clients read, <table>, over every slice:

  • InnoDB, Aria, RocksDB: a Spider table partitioned by cdc_source, each slice's partition reading its table by name (the db tag spider, added with the slice).
  • S3 and packed Aria: the same Spider table partitioned by cdc_source and the period, each partition reading the slice's S3 (or packed Aria) table of that period directly. The plugin that rebuilds a partition repoints the shared table before it drops the table it replaced.
  • PostgreSQL: a view UNION ALL of the slices' tables (PostgreSQL appends them, each slice's partitions pruned in its branch).

A table of that name that is not such a front (an index filled it alone before) is never dropped: WARN0379 says so, as any failure to make the front, with the reason.

Spider link passwords. The Spider tables of a child (the fronts of sliced, S3 and packed Aria indexes, the parallel views) read the child's own tables through local accounts whose passwords replication-manager draws on the child and never shows. A link is made once and kept. To give them new passwords (a security rotation), use Rotate Spider Link Passwords in the child's analytic settings (POST /api/clusters/{cluster}/replication-plugin-actions/rotate-spider-links, grant cluster-replication): each front reading through a key is locked, the key made again, then the front flushed, so none keeps the old password.

A packed Aria index (since 4.0.1, enterprise)

Target engine aria-packed: each period partition of the index is an Aria table packed by aria_pack (read-only, compressed), read through a Spider front of the same partitioning, as S3 tables are, on the child's own disk. The changes wait in InnoDB delta tables (the live view <table>_live reads the front and the delta); a changed partition is rebuilt from its delta into a new Aria table, packed, and swapped in. A version (the first load, a reload) has every closed partition packed before it is switched in.

  • Who packs: aria_pack works on the closed table files, next to the data directory: the database jobs container runs it (task ariapack, the official MariaDB image has the tool). The child records the tables to pack in replication_manager_schema.cdc_pack_requests; replication-manager dispatches the task; each request ends done or failed with the commands' output. A rebuild round waits at most 30 minutes for its packs; a failed pack keeps the previous packed table and the delta, with the reason in the index status.
  • Partitioned indexes only (partition column and period), the db tag spider on the child.
  • Writers: only the rebuilds write Aria, replication-plugin-rebuild-threads at a time (default 1): parallel loads into Aria contend on its page cache.
  • Large reads of a front (S3, packed Aria, a shared front): Spider spools a large result into a temporary table in the server's tmpdir (spider_quick_mode 3, the spider tag's value). Keep the child's tmpdir on its data volume, the default (./.system/tmp); the notmpdisk tag and prov-db-docker-tmpfs-size put it on a memory tmpfs, which a full read of a large front fills.

Parallel views of an index (since 4.0.1)

An index's option Parallel Views lists named aggregate queries over its table, each with its group items (columns, or expression AS alias), its measures (COUNT, SUM, MIN, MAX, AVG of an expression AS alias; no DISTINCT) and an optional condition:

[{"name": "by_day", "group": ["DATE(entry_d) AS dy"], "measures": ["COUNT(*) AS cnt", "SUM(amount) AS amt"]}]

replication-manager makes for each, in the index's schema on the child:

  • v_<name>, a view to query as any table (SELECT * FROM v_by_day ORDER BY dy);
  • f_<name>(), the function behind it: one GROUP BY per partition of the index, all sent at once through the target's connection keys (Spider, one per DBU of the server), the partial results merged exactly (sums of sums, minimum of minimums, AVG as a sum over a count), returned as JSON;
  • p_<name>(), the same as a procedure (CALL p_by_day()), for a result too large for one JSON value (max_allowed_packet, about ten million rows of a few columns).

The partitions' queries follow the index's partitions as they are added or dropped, and the objects are made again when their definition changes. A failure is WARN0380, with the reason; the index itself is untouched. Empty: no views.

The document id of an index (since 4.0.1)

Every index created from 4.0.1 on carries a document id: a 64-bit number per row, computed from the row's primary key, the same in every engine (InnoDB, Aria, RocksDB, ColumnStore, DuckDB, S3, PostgreSQL, Manticore). It is the last column of the index, replication_manager_doc_id. Manticore uses it as its document id; in the other engines it lets you match the same row across engines, or join a Manticore search result back to its MariaDB row.

How it is computed

  • A primary key of one integer column: that value as is.
  • Any other key: the first 64 bits of the MD5 of the key values joined by |. You can compute the same number yourself in MariaDB or MySQL:
SELECT CAST(CONV(LEFT(MD5(CONCAT_WS('|', ol_w_id, ol_d_id, ol_o_id, ol_number)), 16), 16, 10) AS UNSIGNED) AS doc_id
FROM order_line;

and in PostgreSQL:

SELECT ((('x' || left(md5(concat_ws('|', ol_w_id, ol_d_id, ol_o_id, ol_number)), 16))::bit(64)::bigint)::numeric
        % 18446744073709551616 + 18446744073709551616) % 18446744073709551616 AS doc_id
FROM order_line;

List the key columns in the order of the index's primary key.

Refused at creation, with the reason: a key column that can be NULL, a FLOAT or DOUBLE key column, or a key column in a character set other than utf8mb4, utf8mb3, ascii or binary.

Collisions: two keys can, rarely, give the same 64-bit id. replication-manager checks at the initial load and on every change, and raises the warning WARN0376 naming the index, the id and both keys. A SQL engine keeps both rows; Manticore keeps the row already there. It is never silent.

Turning it off: the index option doc-id (in the index form, or docId in the API) is on by default for a new index. Indexes created before 4.0.1 have none and are not changed. Turning it on or off reloads the index.

A ColumnStore index (since 4.0.1)

An index of a MariaDB child can be a ColumnStore table (engine ColumnStore in the New Child Cluster or the index settings). The child runs the official mariadb image; ColumnStore comes from MariaDB's packages of that release (the engines bundle) and the child gets the mcs and localinfile database tags. The table is made from the index's columns only (ColumnStore takes no key, and some types are widened); its changes go through the index's InnoDB staging and are merged by deleting the changed keys and bulk-loading the rows. A ColumnStore index takes no partition option (ColumnStore organises its own storage). The engine is shown greyed, with the reason, when the child's image cannot load it.

A DuckDB index (since 4.0.1, enterprise)

An index of a MariaDB child can be a DuckDB table (engine DuckDB in the New Child Cluster or the index settings). It is an index of the MariaDB CDC link like any other: the replications list shows it as repl-mariadb-mariadb-cdc with the engine DuckDB. Its changes are applied by the enterprise DuckDB plugin (repl-mariadb-duckdb-cdc), which writes out of the binary log, as the DuckDB engine requires: replication-manager runs it for the DuckDB indexes, and the index list says "DuckDB applied by repl-mariadb-duckdb-cdc". The child gets the duckdb and localinfile database tags. A DuckDB index takes no partition option, and its source tables need a primary key (no partitioned table, no generated, invisible or BIT column, utf8mb4, utf8mb3 or ascii only).

When the DuckDB plugin is not installed on the instance, or the plan does not include the enterprise plugins, the engine is shown greyed with that reason (it names the plugin), and an index of that engine is refused: it is never written in another engine. Children created before keep their DuckDB indexes as they are: nothing to change in their configuration.

An index into an app: Manticore, Valkey, Memcached (since 4.0.1)

An index of a child can also be written into an app of the child cluster instead of its database: a search index in a Manticore app, or a cache in a Valkey (Redis) or Memcached app. In the index settings, set Target engine to manticore, valkey or memcached, and Target app to the app's name (template manticore, valkey or memcached). The index is then shown under that app in the servers table, as a SLAVE Idx row under the app's MASTER row. Such an index is an index of a query, with its document id on, not partitioned, and applied at once (no merge interval).

On Valkey and Memcached, each row of the index is one key, <slave table>:<document id>, its value the row as JSON, for example sales:4711 holding {"ol_o_id":12,"ol_number":3,"i_name":"pen","amount":2.5}. A deleted row deletes its key. The document id is the one of every engine (above): a single integer key as is, else the first 64 bits of the MD5 of the key, so an application computes the key of a row from its primary key. The index also keeps a few keys of its own under <slave table>:_schema and <slave table>:_sk:* (which keys a change of a joined table reaches).

  • Key TTL (target-ttl, seconds): how long each key lives; empty or 0, it never expires.
  • Valkey: the app's VALKEY_PASSWORD secret is used for AUTH. An initial load first removes the keys of the index's former load.
  • Memcached: Target app can name several Memcached apps separated by commas, a cluster of memcache: each key is written on one of them, chosen by consistent hashing (ketama, the same as libmemcached's, so a client with a ketama ring of the same apps finds it). Ring points per app (target-vnodes, default 160) tunes it. Memcached may evict any key and cannot list its keys: a row deleted while the key that tracks it was evicted, or a key of a former initial load, stays until its TTL. On Memcached, set a TTL.

An index into Elasticsearch, Kafka or RabbitMQ (since 4.0.1)

Three more apps take an index, the same way (Target engine and Target app):

  • Elasticsearch (template elasticsearch, one node, security on: its ELASTIC_PASSWORD is generated for the app and used by replication-manager): each row of the index is one document, its _id the document id, its fields the row's columns; a deleted row deletes its document. Target name sets the Elasticsearch index (empty: the slave table in lowercase). The index's own records (which documents a change of a joined table reaches) are kept in <index>-rm-meta.

  • Kafka (template kafka, one node in KRaft mode): each row change is a message on a topic (Target name, empty: the slave table), its key the document id, its value the row; a deleted row is a tombstone (a message with no value), so a compacted topic keeps the latest row of each key. Each checkpoint is written in one Kafka transaction with replication-manager's position: a consumer that reads committed messages (isolation.level=read_committed) gets every change exactly once, even when the plugin is killed in the middle. Kafka is an enterprise plugin (it needs an enterprise plan).

  • RabbitMQ (template rabbitmq): each row change is a persistent message published to an exchange (Exchange, target-name, empty: repman-cdc, a topic exchange created when missing), its routing key the slave table or, with Routing key id (target-routing-key), the document id. The headers say what it is: rm-op (upsert or delete), rm-id (the document id), rm-table, rm-format, rm-payload. A deleted row is a message with an empty body and rm-op = delete. Each checkpoint is published in one AMQP transaction with replication-manager's position, so a change is never published twice, even when the plugin is killed. Bind your queues to the exchange before the index starts: a message the exchange routes nowhere is dropped.

Joined tables on Kafka and RabbitMQ. An index can join other tables (orders with their items, products with their category). replication-manager keeps its own copy of the index in the child cluster's database (tables <slave table>_rm_mirror*), so when a joined row changes, it knows which documents it reaches: each of them is published again with its new values (rename a category: one message per product of that category), and a document that no longer matches the join is published as a delete.

Each of these apps shows its indexes as SLAVE rows under its MASTER row, named after the source server and the plugin, for example db1.dev (elasticsearch-cdc).

Free and enterprise

Each CDC destination and each format is free (every replication-manager, Cloud18's open sign-up included) or enterprise (it needs an enterprise plan: partner, support or developer; its plugin is delivered signed with the enterprise plugins, and an installation without it refuses the index with that reason).

Destination or format Tier
MariaDB child (InnoDB and the other MariaDB engines) free
ColumnStore free
Manticore free
Memcached free
Elasticsearch free
RabbitMQ free
PostgreSQL child, tables copied free
DuckDB enterprise
S3 partitions enterprise
PostgreSQL child, indexes of a query enterprise
The PostgreSQL feed (a PostgreSQL source into MariaDB) enterprise
Kafka enterprise
Valkey (Redis) enterprise
format json (and columns) free
formats msgpack, avro enterprise

Format and payload of what is written

Two index settings, the same for every destination, decide what is stored:

Destination Format (target-format, default first) Payload (target-payload)
a database engine (InnoDB, Aria, RocksDB, TidesDB, PostgreSQL) columns, json, msgpack, avro row, event
ColumnStore, DuckDB, S3 columns row
Valkey json, msgpack, avro, columns row, event
Memcached, Kafka, RabbitMQ json, msgpack, avro row, event
Elasticsearch columns (the document's fields) row, event
Manticore columns row
  • Payload row (the default): the value is the row itself, its columns and their values, no envelope.
  • What one message or row stands for, with either payload: an index (joined or not) is published as the states of its documents, one message (or changelog row) per document per checkpoint that changed it. Several changes to the same document within one checkpoint (about 10 seconds by default) give one message, its last state. A document written back to the value it already had gives no message. A document that leaves the index (deleted, or no longer matching a join) gives one delete. This is not one event per source change: exact per-change events, built from the binary log's row images of a single table without a join, are a planned separate mode, not available yet. event: {"op": "upsert" | "delete", "id": "<document id>", "table": ..., "gtid": ..., "ts": <source time>, "row": {...} | null}. A delete stays a delete (a tombstone on Kafka, after the delete event; a key or a document removed elsewhere).
  • json: an object of the columns, numbers for the numeric columns, null for NULL.
  • msgpack: a MessagePack map of the columns, integers as integers, FLOAT/DOUBLE as floats, DECIMAL and BIGINT UNSIGNED as their exact digits in a string.
  • avro: a record derived from the index's columns (each nullable: long for an integer, double for FLOAT/DOUBLE, string otherwise, DECIMAL included to keep its digits; a column name other than letters, digits and _ has them replaced). Without a registry each value is an Avro single-object encoding (C3 01, the 8-byte fingerprint of the schema, the body) and the schema is published: on Kafka on the topic <topic>-schema keyed by the fingerprint, on Valkey and Memcached in <slave table>:_schema. On Kafka, Schema registry (target-schema-registry, an http(s) URL of a Confluent schema registry) registers the schema under <topic>-value and writes each value in Confluent's wire format, so the registry's deserializers read it.
  • Kafka messages also carry the headers rm-format, rm-payload and, for Avro without a registry, rm-schema (the fingerprint).
  • A value the destination does not take is refused when the index is saved, with the values it takes. Changing the format or the payload of an index takes effect when it is rebuilt (a new initial load).
  • json is available to everyone; msgpack and avro come with the enterprise plugins.
  • On a database: columns is the usual table. json, msgpack or avro make it a key-value table: one row per document, replication_manager_doc_id (the key) and value (a JSON column for json, a binary column otherwise). The event payload makes it a changelog: one row per change, rm_seq and rm_n (the checkpoint and the change's order in it), op, the document id, gtid, ts, then the row's columns (or one value column with the encoded event); each checkpoint's rows are written once, in one transaction. Both need InnoDB (or Aria, RocksDB, TidesDB, PostgreSQL).
  • Valkey columns: each document is a hash, one field per column (a NULL column has no field).

The S3 engine of a child on the Cloud18 storage (since 4.0.1)

A MariaDB child can keep indexes in MariaDB's S3 engine (target engine S3). The S3 engine reads its storage keys from its configuration when the database starts, so the short-lived keys of the Cloud18 sign-in cannot serve it. On an instance registered to Cloud18, replication-manager gives the child a bucket and a key of its own, in the storage area of the account the instance is registered with:

  • Dashboard: the child's Configs > Database > S3 Engine Provider, button Use a bucket on the Cloud18 storage.
  • API: POST /api/clusters/{cluster}/settings/actions/cloud18-s3-engine (right cluster-settings).

replication-manager signs in to the storage with the account's stored credential, creates the bucket <your id>-dwh in that account's area, then an access key of that account limited to that bucket. The key is kept once (encrypted at rest, never shown, never in a log) and reused; it is the S3 provider cloud18-dwh of the child, set as the S3 engine's provider with the s3 database tag. A rolling restart of the child's databases then loads the S3 engine with it. The answer names the bucket and what was made, never a key.

How an S3 index is laid out (since 4.0.1). An S3 index is partitioned (its partition column and period are required). Each partition is its own S3 table, <index table>_<partition>, and the index table itself is a Spider table of the same partitioning that reads them, so a query reads one table and only the partitions its WHERE selects. The changes wait in InnoDB delta tables; a changed partition is rebuilt into a new S3 table and swapped in with RENAME TABLE, never with EXCHANGE PARTITION: MariaDB 12.3's S3 engine crashed the server when a partitioned S3 table was opened during an exchange. <index table>_live shows the S3 rows and the waiting changes together.

The child therefore needs the spider database tag besides s3 (the engines bundle fetches Spider of the server's release; a restart loads it): without it the index is refused with that reason. replication-manager makes a local, read-only account and a Spider server for the schema (its password drawn once, kept only by the database, never shown). Keep spider_direct_aggregate off on such a child: MariaDB 12.3.4's Spider returns 0 for SUM, MIN or MAX over an exact primary-key lookup when it is on.

Reseeding a staging or a child cluster from its parent (since 3.1.45)

Bootstrap Staging From Parent (API POST /api/clusters/{staging}/actions/staging-reseed-from-parent) reloads an existing staging cluster with the parent's data of now:

  1. Stops the master's replication from the parent: its position in the parent's GTID domain stops moving.
  2. Takes a fresh logical backup of the parent when the last one is behind that position. A reseed never takes the parent's domain back: the master already holds in its binary log the later transactions of the parent it replicated, and with gtid_strict_mode it refuses to write an older one after them (error 1950). The fresh backup is past that position, the parent's domain only moves forward. A new cluster holds none of the parent's domain: its creation does not need it. MariaDB.
  3. Restores that backup on the master and points its replication from the parent at the backup's position, as at the creation.
  4. Refreshes the staging server: a replica that applied all the master wrote is detached as the new staging server, and the former staging server is reloaded from the staging master's own backup, taken after its restore, never from the parent's: it holds the restored data and the master's position in every domain, so the former staging server does not replay the restore through replication.

The restore on the master

A backup restored on a master with the binary log on goes to every replica through its binary log. While it runs (since 3.1.45):

  • The binary logs stay bounded: on MariaDB 11.4 and later, max_binlog_total_size is held at 2G on the master and its replicas, and slave_connections_needed_for_purge at 0 on the replicas (with the default 1, a server with no replica of its own never purges); MariaDB purges by itself. The values come back at the end: the plan's max_binlog_total_size under the dynamic config, the one found otherwise.
  • The restore pauses on each binary log rotation until every replica applied the rotated binary log with no delay (Seconds_Behind_Master 0). A replica whose replication is stopped, or delayed on purpose (hosts-delayed, MASTER_DELAY), does not take part. WARN0254 names the replica the restore waits for. There is no timer: a restore can take days.
  • Semi-sync is paused on the master (rpl_semi_sync_master_enabled, rpl_semi_sync_source_enabled on MySQL and Percona 8.0.26 and later) and set back on at the end, only when it was on: the pause already holds the restore for the replicas, and every commit of the restore waited for an acknowledgement (a 858 MB backup took 16m51s with it, 12m37s without).
  • The restore ends once every replica reached the master's position read when the restore wrote its last transaction, and a staging replica is detached only then. A replica whose applied position does not move for 90 s, a broken replication or an SQL error ends that wait.

Cancelling a restore: a running logical reseed, from the parent or from the cluster's own backup, single file or splitdump, stops with GET /api/clusters/{cluster}/servers/{server}/actions/job-cancel/reseedmysqldump, also while it is paused on a rotation. The binary log limit and semi-sync come back at once, without waiting for the replicas. The data is then incomplete: the server's replication stays stopped, WARN0252 says so until a reseed of that server ends. A reseed from the parent refused before anything was loaded (no parent backup, no parent master, a reseed already running) starts the master's replication from the parent again.

Outside a restore, prov-db-binlog-total-size-pct (default 25) gives max_binlog_total_size as that share of prov-db-disk-size, never under 2G (template variable %%ENV:SVC_CONF_ENV_MAX_BINLOG_TOTAL_SIZE%%, MariaDB 11.4 and later): the binary logs bounded by the plan, not only by prov-db-expire-log-days, once the replication ruleset of the configurator sets it.

4.4.12.1 Staging config important setup :

## 4.4.12.2 To be change when proxy tracking state is enable
haproxy = false

## 4.4.12.3 Specify an other domain for staging
prov-db-domain = "3"

## 4.4.12.4  Specify an other source of replication for the staging cluster
replication-source-name = "staging"

## 4.4.12.5 Point the production cluster to enable mutti-tiers cluster master prod to master staging extra replication source
replication-multisource-head-cluster="prod-cluster"

## 4.4.12.6 Proxy Upgrade script
db-servers-state-change-script = "/data/repman/script/database_state_change.sh"

## 4.4.12.7 To enable ssh to database and proxy hosts, use ssh-keygen ssh-copy-id for first deployment
onpremise-ssh = true
onpremise-ssh-credential = "root:"
onpremise-ssh-private-key = "/root/.ssh/id_rsa_preprod"
scheduler-jobs-ssh = true

## 4.4.12.8  To automate logical backup  
monitoring-scheduler = true

4.4.12.9 Lesson learns:

  • Production and staging monitoring and replication users should have same name same password so that 2 similar users does not get different password in staging after an initial restore from production
  • Mydumper dist version test your restore

4.4.12.10 Todo :

  • New cluster variable --topology-staging bool
  • New cluster variable --topology-staging-refresh-script
  • New cluster variable --topology-staging-post-detach-script ( obfuscation data do whatever have to be done in db)
  • Cluster menu api call to trigger: Staging refresh

Api call should trigger similar script that will comes embedded in share

#!/bin/bash

# Variables
REPLICATION_MANAGER_USER="admin"
REPLICATION_MANAGER_PASSWORD="xxx"
REPLICATION_MANAGER_URL="https://repman-01:10005"
REPLICATION_MANAGER_CLUSTER_NAME="staging"
REPLICATION_MANAGER_HOST_NAME=$1
REPLICATION_MANAGER_HOST_PORT="3306"
NB_SLAVES=0

##### This bloc is for getting the replication-manager token
GET="wget -q --no-check-certificate -O- --header Content-Type:application/json"
AUTH_DATA="{\"username\": \"$REPLICATION_MANAGER_USER\", \"password\": \"$REPLICATION_MANAGER_PASSWORD\"}"
TOKEN=$($GET --post-data "$AUTH_DATA" --header Accept:text/html $REPLICATION_MANAGER_URL/api/login)

function get {
    $GET --header Accept:application/json --header "Authorization: Bearer $TOKEN" "$@"
}

# Counting the slaves, depending, we will play one of the two following scenarios
NB_SLAVES=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq length)
echo $NB_SLAVES

# Scenario 1 : 2 slaves, then we will stop the replication on one that will be the "staging"  
if [ $NB_SLAVES -eq 2 ]; then
  echo "picking first slave \n"
  ID=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].id' | sed 's/"//g' )
  PORT=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].port')
  echo "$ID:$PORT"
  echo "Reseting first slave \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/reset-slave-all
  sleep 2
  echo "Stopping first server slave replication \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop-slave
  sleep 20
  echo "Stopping first mariadb server \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop
  echo "Starting first mariadb server \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/start
  loop=true
  while $loop; do
    sleep 1
    IO_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].replications[0].slaveIoRunning.String')
    SQL_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].replications[0].slaveSqlRunning.String')
    echo $IO_THREADS
    echo $SQL_THREADS
    if [ "$IO_THREADS" == "\"No\"" ] || [ "$SQL_THREADS" == "\"No\"" ]; then
      loop=false
    fi
  done

  echo "Getting and saving slaves initial statuses \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[1].replications'>replications.save

  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/reset-slave-all
  sleep 2
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop
  echo "Waiting for database server $ID to status failed \n"
  loop=true
  while $loop; do
    ID_CHECK=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select(.state == "Failed").id' | sed 's/"//g')
    if [ "$ID_CHECK" == "$ID" ]; then
      loop=false
    fi
  done
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/start
fi

if [ $NB_SLAVES -eq 1 ]; then
  echo "picking last slave and founding standalone \n"
  ID=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select( .state == "StandAlone" ).id' | sed 's/"//g')
  echo "found standalone server $ID \n"
  echo "reseting master position on standalone \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/reset-master
  echo "setup replication manager for reseeding \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autoseed
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-logical-backup
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-force-restore
  sleep 2
  echo "Stopping database server $ID \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/stop
  echo "Waiting for database server $ID to status failed \n"
  loop=true
  while $loop; do
    ID_CHECK=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select(.state == "Failed").id' | sed 's/"//g')
    if [ "$ID_CHECK" == "$ID" ]; then
      loop=false
    fi
  done
  echo "Start database server $ID \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID/actions/start
  sleep 20
  echo "Reseting replciation manager settings for reseed = false \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autoseed
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-logical-backup
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/settings/actions/switch/autorejoin-force-restore

###### Now set last slave as standalone

# Get the last available slave
ID_SLAVE=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/servers | jq -c '.[] | select(.state == "Slave").id' | sed 's/"//g')
  echo "last slave found for staging $ID_SLAVE \n"
  echo "Stopping replication on last slave \n"
  get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/stop-slave
  loop=true
  while $loop; do
    echo "Waiting replication to stop \n"
    sleep 5
    IO_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq --arg id "$ID_SLAVE" '.[] | select(.id == $id).replications[0].slaveIoRunning.String')
    SQL_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq --arg id "$ID_SLAVE" '.[] | select(.id == $id).replications[0].slaveSqlRunning.String')
#    IO_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[] | select( .id == $ID_SLAVE ).replications[0].slaveIoRunning.String')
#    SQL_THREADS=$(get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[] | select( .id == $ID_SLAVE ).replications[0].slaveSqlRunning.String')
    echo $IO_THREADS
    echo $SQL_THREADS
    if [ "$IO_THREADS" == "\"No\"" ] || [ "$SQL_THREADS" == "\"No\"" ]; then
      loop=false
    fi
    done
    echo "Saving replication info in replication.save \n"
    get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq --arg id "$ID_SLAVE" '.[] | select(.id == $id).replications' > replications.save
#    get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/topology/slaves | jq '.[] | select( .id == $ID_SLAVE ).replications'>replications.save
    echo "Reset all replication information \n"
    get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/reset-slave-all
    sleep 2
    get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/stop
    sleep 2
    get $REPLICATION_MANAGER_URL/api/clusters/$REPLICATION_MANAGER_CLUSTER_NAME/servers/$ID_SLAVE/actions/start
fi
  • Adapt the script to not stop start the database nodes
  • Adapt the script to use env variables deploy in the bash instead of hardcoded variables

Today we can customize status change script to trigger some dedicated proxy config reload bu need native proxy integration

4.4.12.11 To be removed after integration

database_state_change.sh

#!/bin/bash
# This script is given as sample and will be overwrite on upgrade
# db-servers-state-change-script
echo "Database state change script args"
echo "Script:$0, Cluster:$1, Host:$2, Port:$3, State:$4, OldState:$5"
if [ "$4" = "StandAlone" ]; then
        scp /data/repman/script/ha.cfg.$2 root@staging-proxy:/etc/haproxy/haproxy.cfg
        ssh root@staging-proxy "systemctl reload haproxy"
fi

4.4.12.12 Todo

  • New cluster variables haproxy more variables haproxy-staging-port, haproxy-staging-bind, haproxy-staging-backend
  • New cluster variable proxysql-write-track-state="master|standalone" , proxysql-read-track-state="slave|standalone"