Skip to main content

TMQ Continuous Synchronization

info

TMQ subscription synchronization continuously reads data and metadata from source topics and writes them to a target database. It is log subscription, distinct from query migration, Kafka ingestion, and dedicated dual-active replication. Prepare source topics and the target database and choose the starting position and consumer group before creation. During operation, check both consumption progress and target records. Disabling deletion options is not a reliable deletion-prevention boundary.

The one-way synchronization example uses two TDengine TSDB Enterprise v3.4.3.12 test databases.

Where to operate: taosExplorer → Data In → TDengine Data Subscription, or taosx run on the command line. Run topic and data queries in the taosExplorer Data Browser or taos CLI.

TMQ is TDengine's data subscription mechanism. It is neither external Kafka ingestion nor a dedicated dual-active task. Do not build dual-active replication with two ordinary tasks in opposite directions.

The first exercise uses only isolated test source and target databases, with no table or data deletion. Disabling deletion options alone does not guarantee that the target receives no deletions. If a production solution must block deletion propagation, first confirm Deletion Propagation Limitations. Do not deploy the commands on this page directly in production.

1. Prepare a Source Topic and Target Database​

Have an authorized TDengine TSDB administrator run these separately in the test environment. Use new names if any are taken. Keep database precision identical on both sides. Source WAL retention must cover planned downtime and catch-up time.

Source:

CREATE DATABASE taosx_sync_src PRECISION 'ms' WAL_RETENTION_PERIOD 86400;
CREATE STABLE taosx_sync_src.meters
(ts TIMESTAMP, value DOUBLE) TAGS (site VARCHAR(16));
CREATE TABLE taosx_sync_src.meter_1 USING taosx_sync_src.meters TAGS ('lab');
CREATE TOPIC taosx_sync_topic WITH META AS DATABASE taosx_sync_src;

Target:

CREATE DATABASE taosx_sync_dst PRECISION 'ms';

WAL_RETENTION_PERIOD is measured in seconds. The example's 86400 means one day, not a recommended value for every workload. Choose the actual value by recovery time, catch-up speed, and storage capacity. Topic WITH META includes schema changes. To replicate schema, do not substitute a data topic containing only query results. See Topic Management for topic and subscription permissions.

1.1 Prepare the Topic in the GUI​

Do not create it again if the SQL topic above exists. For the GUI path, have an authorized source administrator perform these steps:

  1. Log in to the source cluster's taosExplorer, open Data Subscription, and click Add New Topic.
  2. Select Wizard, enter topic name taosx_sync_topic, and select taosx_sync_src as Database. If it is absent from the list, check the connected cluster, source database preparation, and account visibility. Do not choose an unrelated database.
  3. Explicitly select Database as Type rather than leaving a supertable or subquery type. This example replicates schema and data in the source database, not just one supertable.
  4. Enable Sync Meta, review the name, objects, and metadata scope, then click Create. If the button is unavailable, check required fields and type. Do not switch to SQL mode to bypass missing preparation.
  5. Find the topic in the source topic list, copy its DSN, and check the server, port, and topic name individually. Confirm that the identity has subscription permissions. Do not use a source database connection string as the DSN of this created topic.

Database type and Sync Meta switch in the source topic wizard

The image only shows where type and metadata options are located. Database must still be set to the actual source database. Creation is unavailable with incomplete required fields. After topic creation, create the target task and verify data below. A configuration screenshot is not evidence of successful synchronization.

The source topic DSN lets the target task read the source cluster; it is not the target write address. Protect copied identity information as sensitive configuration. Across hosts, do not reuse the source browser address or localhost unchanged on another taosX host. Topic creation changes the source and requires an authorized administrator.

2. Create a Continuous Synchronization Task​

2.1 Create in the GUI​

  1. Log in to the target cluster's taosExplorer and open Data In → Create New Task. Enter quickstart_tmq, select TDengine Data Subscription, and select target database taosx_sync_dst.
  2. Paste the source topic connection into Topic DSN under Connection Configuration. An isolated same-environment exercise with unchanged default credentials can use tmq+ws://root:taosdata@127.0.0.1:6041/taosx_sync_topic. In production, use an approved source identity and source taosAdapter address. A database name is not an already-created topic name.
  3. Click Check Connectivity. On failure, first check network access, identity, and subscription permissions from the actual taosX execution host to the source. Do not bypass the issue by changing topic names or broadening permissions.
  4. Expand Subscription Settings. Explicitly select initial position earliest, enter subscription group ID taosx_sync_demo, client ID quickstart_tmq_client, and timeout 0 seconds. The GUI requires a client ID; an automatically generated source group name does not replace it.
  5. For the initial historical-plus-continuous exercise, enable Sync Persisted Data. Sync Table Deletions and Sync Data Deletions are initially enabled in the GUI. Check them against the approved replication scope. Disabling can be requested, but it does not establish reliable target deletion protection. Perform no deletions at either end during this first exercise. See Deletion Propagation Limitations for production handling.
  6. Sync Higher-Version Data is initially disabled. It is not a universal version-compatibility switch. Check supported combinations first for cross-version needs; do not enable it blindly to resolve write failures.
  7. Leave Transformations empty initially. To rename objects or add tags, follow Object Selection and Renaming, previewing and verifying each rule. Do not copy conflicting object definitions.
  8. Review Advanced Options. Configure WebSocket compression here if needed and confirm dependencies on both sides. After submission, return to the task list, confirm the original task starts, and perform section 3 verification.

Source Topic DSN field in the target task

The input example's localhost is not the actual source address. After pasting, check the protocol, source taosAdapter, topic, and identity individually. Confirm connectivity from the taosX host running the task, not only from the browser host.

TMQ initial position, group, client, timeout, snapshot, and deletion options

The image shows initial values for a new task. It does not mean every workload should retain deletion switches or prove that disabling them isolates all deletions. An empty subscription group can generate a name automatically. Record the actual group name to diagnose positions; this example sets it explicitly for querying. Determine templates, transformations, and deletion semantics before creation, not after data propagates.

2.2 Create an Equivalent Link from the CLI​

For the first exercise, choose either a service task or a standalone taosx run, not both with the same consumer group. The following examples apply only where source and target share an isolated cluster, taosAdapter and taosx run share the same runtime environment, and default root / taosdata credentials are unchanged. Substitute both identities and addresses in actual deployment. The command waits continuously; stop it in the foreground with Ctrl+C.

Run in Bash on a taosX command-line host that can reach both sides:

taosx run -f 'tmq+ws://root:taosdata@127.0.0.1:6041/taosx_sync_topic?group.id=taosx_sync_demo&client.id=quickstart_tmq_client&auto.offset.reset=earliest&experimental.snapshot.enable=true&timeout=never' -t 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_sync_dst'
warning

Keep outer DSN quotes to prevent shell interpretation of &. URL-encode reserved characters in credentials. The taosx run commands above omit deletion keys, so direct DSN with.meta.delete and with.meta.drop both default to enabled. Do not infer these defaults from GUI initial values. This example verifies only non-deletion data; it proves neither replication of all schema operations nor target deletion isolation.

ParameterSetting and meaning in this example
Path taosx_sync_topicAn existing source topic name, not the target database name.
group.idA consumer group dedicated to this target. Do not inadvertently share a group across targets, or they may divide source partitions.
auto.offset.reset=earliestStart at the earliest readable position only if no committed position exists. Existing positions take precedence; this does not mean full rereads on every restart.
experimental.snapshot.enable=trueEnable historical snapshot reads, then continue reading the WAL. Still check whether the source retains the history.
timeout=neverNo separate max.polling.timeout is set here; keep waiting without new messages. Without a timeout parameter, the production entry point normally uses a 5-second idle wait, unsuitable for continuous operation.
with.meta.delete, with.meta.dropBoth default to true in direct DSNs. Only exact lowercase false requests disabling; invalid values such as empty strings, 0, or False fall back to enabled. The limitations below still apply after disabling; this is not sufficient for a production deletion-prevention plan.

For concurrency, commits, progress refresh, timeout precedence, and effective paths, see TMQ Synchronization Parameters. Verify defaults and applicability before using low-level connector extension parameters.

Retain the default write method initially; do not tune by switching to prefer=interlace. This method has a separate idle-exit rule: it can exit normally when no message is returned and more than the internal 5-second threshold has elapsed since the latest commit. An infinite timeout does not override it and therefore does not guarantee continuous waiting.

Use an explicitly created topic initially to avoid entering a database or supertable name as a topic and triggering automatic topic preparation and additional permission requirements.

2.3 Concurrency and upgrades​

Number of Consumers sets read concurrency per Topic through read_concurrency or num.of.consumers in the source FROM DSN. Omitted or 0 divides the source database's vGroup count by 4, rounds up, and starts at least 1 Consumer. Explicit positive values are capped at the source database's vGroup count.

Older automatic mode started one Consumer per vGroup. After upgrading, newly planned tasks with multiple vGroups use fewer source connections and may have lower peak read throughput. XNode jobs resumed directly from saved configurations retain their stored read concurrency. To keep one Consumer per vGroup after replanning, explicitly set the source database's vGroup count.

Number of Writers sets write concurrency per Consumer, with a minimum of 1. A new taosExplorer form fills in 1; saving the field blank omits the parameter. The source FROM DSN uses the first configured value in this order: write_concurrency, num.of.writers, then the service process's TMQ_WRITE_CONCURRENCY environment variable. If all are unset, it uses 1. This applies only in interlaced write mode, or with enable.concurrent.polling enabled and no transformation actions. Other paths write serially per Consumer.

Existing tasks saved with 0 use 1 on their next start rather than selecting automatically by CPU count. After upgrading, these tasks may use fewer target write connections and have lower peak write throughput. Explicitly set a positive integer for multiple writers. Retain original configuration before tuning and verify source positions and target data afterward; connection counts alone are insufficient.

3. Verify Initial and Continuous Writes​

Write a test record before and after startup, recording actual write times and values. Run in the source cluster's taosExplorer Data Browser or taos CLI:

INSERT INTO taosx_sync_src.meter_1 VALUES (NOW, 10.5);
SELECT ts, value, site FROM taosx_sync_src.meter_1 ORDER BY ts;

Run in the target cluster's taosExplorer Data Browser or taos CLI:

DESCRIBE taosx_sync_dst.meters;
SELECT ts, value, site FROM taosx_sync_dst.meter_1 ORDER BY ts;

Compare source timestamps, values, and tags record by record. Then write another timestamp to confirm continuous replication. Use distinct primary timestamps for test records to avoid overwrites being mistaken for missing rows. To verify deletions or schema changes, use separate test objects with authorization, not business tables.

4. Inspect Subscription Progress​

4.1 Inspect Service Task Activity and Statistics​

After submitting a GUI task, find the original quickstart_tmq task in the target taosExplorer task list and inspect execution status. Expand its activity information and check errors in queuing, startup, source connections, and target writes. Use View to open dynamic statistics and record the task ID, run start, and latest window. Queued does not mean subscribed, and cumulative reads are not the target's unique row count.

Example startup, queuing, and creation activity in an expanded task row

This image is an activity example from a separate older task. Its name, ID, and times do not belong to this exercise; it locates the expansion control and activity information. Interpret activities by occurrence time. A startup record does not mean the task remained healthy afterward. On error, record the first complete error and relevant time, then check metrics and target data.

After opening metrics, check in this order:

  1. Under Current Run, check start_time, then observe whether messages grows within the same run. No growth without new messages can be normal idle behavior.
  2. Use messages_of_meta and messages_of_data to identify message categories, then check write errors and the target. Message counts are neither table counts nor business-row counts; subtraction cannot calculate lost records.
  3. Under Sync Progress, compare consumed and latest positions for every Topic and vgroup. Interpret snapshot and WAL phases separately. If progress is absent or stale, use the source query in the next section. Missing progress does not mean zero backlog.

See TMQ Task Statistics for field meanings and illustrations. Even if statistics keep growing, compare them with the target query results in section 3.

If no task appears, first check the target-cluster login and filters. If the task exists but statistics do not update, check whether it started, the source has new data, and source partitions are actually assigned. Retain error times and messages first, query source subscription positions below, then query the target to verify. See Logs and Performance for actual log and metric retrieval steps.

4.2 Inspect Source Positions​

Run in the source cluster's taosExplorer Data Browser or taos CLI with an account allowed to query system information:

SELECT topic_name, consumer_group, vgroup_id, consumer_id, `offset`, `rows`
FROM information_schema.ins_subscriptions
WHERE topic_name = 'taosx_sync_topic'
AND consumer_group = 'taosx_sync_demo';

Snapshot-phase positions may start with tsdb:; the WAL phase shows consumed and latest versions. Observe each vgroup, not just one row. rows is a consumption statistic, not the unique count successfully written to the target. Nearby positions do not replace target queries. If no results appear, first check the source cluster, topic, actual group name, and whether the task has subscribed, then check permissions and logs.

5. Troubleshooting​

SymptomNext action
Topic missing or subscription failsCheck the actual topic name, source address, and subscription permissions. Do not immediately substitute a database name to bypass the issue.
New data arrives but old data is incompleteCheck initial starting position, existing group positions, snapshot options, and source historical retention.
Target contains only some objectsCheck topic scope, other consumers in the group, and table-creation permissions.
Deletions are not synchronizedConfirm topic type and corresponding deletion options. Do not test deletions directly on business targets.
taosx run exits after new messages stopCheck the actual source DSN's timeout and max.polling.timeout and look for idle-timeout records. Explicitly configure infinite waiting as above for continuous operation. Do not mistake normal idle behavior for source disconnection.
Writes grow but progress is missingQuery the actual source group and every vgroup position first, then check query permissions and logs. Progress refresh changes do not repair target writes or missing history.
Logs show Consumer all deadThis error causes execution failure when triggered by a periodic check. A final check during stopping or completion can also log the same error without establishing failure. Judge by task status and surrounding logs. Save the topic, actual group, and source subscription results, then investigate why consumers exited or lost assignments. Do not conceal the error by reducing refresh frequency; check original task status to see whether the service retries.
Gaps after downtimeCheck whether downtime plus catch-up exceeded WAL retention. Plan backfill by object and time window rather than merely changing groups and rerunning.

For other task, write, and runtime issues, see Troubleshooting by Symptom.

6. Stop and Resume​

After stopping a service task, restart the original task. For foreground CLI, use Ctrl+C and retain the same topic and consumer group when rerunning. Before changing addresses, identities, or targets, save the actual group name. Do not assume a regenerated group name matches the original link. Recovery remains limited by available source positions, history, and WAL retention. Successful writes whose acknowledgments are incomplete can replay; verify target results.

Neither commit counts nor consumption positions alone prove that a position has been saved successfully. Concurrent-read commit batches count messages, not rows, and the idle commit interval is not a fixed schedule. Waiting one commit interval alone does not establish that shutdown or source-data deletion is safe. Retain source positions and target query results before and after stopping. Verify schema, timestamps, values, and tags for the interruption window.

warning

Do not delete consumer groups, topics, or local state as routine recovery, or assume changing auto.offset.reset resets existing positions. If rebuilding or backfilling is genuinely required, first record original progress and gap ranges, then execute in isolation under the approved plan.

7. Limitations​

7.1 Multiple Topics and Object-Name Entry Points​

A DSN path can list multiple topics in the same source cluster, separated by ASCII commas, such as topic1,topic2. The identity must be able to subscribe to all of them. For recovery, record the same group's position for each topic and vgroup. Start with one explicit topic and expand only after confirming schema and data semantics.

Subscription synchronization also has an advanced path: use a database, supertable, or child-table name as the source object and prepare topics automatically. This involves source topic creation and additional permissions, unlike read-only subscription to existing topics:

Source DSN pathObject resolution and preparation during production execution
Single nameMatch an existing topic first; if none matches, check for a database. A name matching an existing topic does not by itself mean the whole database is read.
Database name with use.topic.namePrepare a database-level WITH META topic using the specified name. This option does not support multiple objects.
数据库.表名If the preceding matches fail, check the source table. A supertable gets a derived metadata topic; a child or regular table gets a query topic, with different schema-propagation coverage.
Multiple comma-separated namesExisting topics and databases can be combined; arbitrary combinations of multiple 数据库.表名 entries are unsupported.

Initially use the topic explicitly created above. Before expanding scope, have the source administrator record actual objects, topic definitions, and creation/cleanup ownership and confirm the required permissions. Validate the definition even for an existing same-named topic, not just its name. Connectivity checks do not create missing topics. Changing a failed check's input to a database name is not a general fix. See TMQ Synchronization Parameters for source options and target-table naming applicability.

7.2 Deletion Propagation Limitations​

Sync Table Deletions, Sync Data Deletions, and their DSN keys express replication intent, but disabling them is not a reliable target deletion-prevention boundary. v3.4.4.2 fixes the issue where task splitting changed an explicit false back to true. For older versions, confirm whether the exact delivered version includes this fix. Composite-metadata filtering and raw-message write paths still have independent limitations; blocking every deletion cannot be guaranteed. Changing write strategy or disabling concurrency alone does not establish that the issue is avoided.

If the target must retain data deleted at the source, defer production deployment of that plan. Ask technical support to confirm the exact taosX, source/target TSDB, and supporting client versions and the official support or fix conclusion for that combination. After confirmation, separately verify table deletion, data deletion, schema changes, and interruption recovery in an isolated test database, retaining target results. Without that conclusion and verification evidence, disabling switches does not replace plan review. Do not test deletions on business tables.

Ordinary TMQ synchronization does not provide dual-active loop prevention or automatic business failover. Continuous replication can propagate incorrect writes and authorized deletions; it does not replace independent backups. Validate cross-version, cross-precision, and special table types for the exact combination. Do not infer general support from this example.