Sources
Connect CockroachDB as a source
Create a read-only service account, enable changefeeds and connect CockroachDB to Artie, so your pipeline replicates the tables you choose.
Prerequisites
- A CockroachDB cluster with changefeeds enabled. 4. Enable changefeeds has the commands.
- The cluster’s host and port. The default port is
26257. - The name of the database you replicate.
- A service account username and password. 1. Create a service account has the commands.
Prepare CockroachDB
Run these commands on your CockroachDB cluster. The Prepare CockroachDB step of the pipeline setup shows the same commands.
1. Create a service account
Create the user Artie connects with. On CockroachDB v23 or later, run:
CREATE USER artie WITH LOGIN PASSWORD 'YOUR_PASSWORD' VIEWCLUSTERSETTING;On CockroachDB v22, add CONTROLCHANGEFEED:
CREATE USER artie WITH LOGIN PASSWORD 'YOUR_PASSWORD' CONTROLCHANGEFEED VIEWCLUSTERSETTING;Replace YOUR_PASSWORD with the user’s password.
2. Grant read-only access
Grant the service account read access to each schema you replicate from:
GRANT USAGE ON SCHEMA "public", "SCHEMA_NAME" TO artie;
GRANT SELECT ON ALL TABLES IN SCHEMA "public", "SCHEMA_NAME" TO artie;
ALTER DEFAULT PRIVILEGES IN SCHEMA "public", "SCHEMA_NAME" GRANT SELECT ON TABLES TO artie;Replace public and SCHEMA_NAME with the schemas you replicate from.
3. Configure garbage collection
gc.ttlseconds defaults to 4 hours. We recommend at least 12 hours.
After a pause or outage, Artie restarts the changefeed from the last resolved timestamp it saved. CockroachDB rejects a start time older than this window, so set it longer than your longest expected pause. A shorter window keeps less multiversion concurrency control (MVCC) history on disk.
Check the current value:
SHOW ZONE CONFIGURATION FROM DATABASE DATABASE_NAME;Set the window to 12 hours, which is 43,200 seconds:
ALTER DATABASE DATABASE_NAME CONFIGURE ZONE USING gc.ttlseconds = 43200;Replace DATABASE_NAME with the database you replicate.
4. Enable changefeeds
Turn on rangefeeds and changefeeds for the cluster:
SET CLUSTER SETTING kv.rangefeed.enabled = true;
SET CLUSTER SETTING feature.changefeed.enabled = true;On CockroachDB Basic and Standard, kv.rangefeed.enabled is on by default.
Connect CockroachDB in Artie
These steps cover the source part of the pipeline setup. For the whole flow, see the quickstart.
Choose the source
On Choose your source, select CockroachDB, then select Continue.
Choose network access
On How would you like to connect your source?, select SSH tunnel, Allowlist Artie IPs, or PrivateLink.
Prepare the database
On Prepare CockroachDB, run the commands in Prepare CockroachDB, then select Continue.
Enter the connection settings
On Connect CockroachDB, fill in the connection settings.
Verify the source
Select Verify source. The step shows Source verified.
Continue
Select Continue.
To check the source later, select Verify later.
When you pick a saved CockroachDB connector that other pipelines use, the setup skips the network access and preparation steps and shows them as done. Connect CockroachDB shows the connector’s details in place of its credential fields. Edit the credentials in Settings → Connectors.
Connection settings
Every field is required.
| Field | Default | Value |
|---|---|---|
| Host | None | The IP address or host name of your cluster, for example server.example.com. |
| Port | 26257 | The port CockroachDB listens on, from 1 to 65535. |
| User | None | The service account user, for example artie. |
| Password | None | The service account password. |
| Database name | None | The database Artie replicates tables from. |
Network access
Artie reaches your cluster through an SSH tunnel, an IP allowlist, or PrivateLink. Connection options describes each method.
Read replica for backfills
To keep backfill reads off your primary, turn on Use a read replica for backfill? and enter Replica host and Replica port. Artie backfills from the replica and keeps reading changes from Host. If Replica port is empty, Artie uses Port.
Advanced options
Advanced options on Connect CockroachDB holds two optional settings.
| Setting | Default | What it does |
|---|---|---|
| Label | None | Tells this connector apart when you reuse it. |
| Message compression | None (default) | GZIP compresses the messages Artie writes to Kafka. See Message compression. |
Changefeed behavior
Artie reads changes with one sinkless changefeed that covers every table in the pipeline. The changefeed emits a resolved timestamp every 30 seconds. After a restart, Artie resumes from the last resolved timestamp it saved.
The changefeed carries new changes only (initial_scan = 'no'). Backfills read the tables directly.
Two column behaviors differ from the source table:
- Artie skips the hidden
crdb_internal_*_shard_Ncolumns that CockroachDB adds for hash-sharded indexes. DECIMALvalues ofNaN,Infinityand-Infinityarrive asNULL.
Next steps
Was this page helpful?
- Need help? Message us on Slack or email [email protected].
- Want a walkthrough? Book a demo.
- LLM? Read llms.txt.