You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/current/v24.3/create-logical-replication-stream.md
-8Lines changed: 0 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -50,14 +50,6 @@ Option | Description
50
50
`cursor` | Emits any changes after the specified timestamp. LDR will not perform an initial backfill with the `cursor` option, it will stream any changes after the specified timestamp. The LDR job will encounter an error if you specify a `cursor` timestamp that is before the configured [garbage collection]({% link {{ page.version.version }}/architecture/storage-layer.md %}#garbage-collection) window for that table. **Warning:** Apply the `cursor` option carefully to LDR streams. Using a timestamp in error could cause data loss.
51
51
<aid="discard-ttl-deletes-option"></a>`discard` | ([**Unidirectional LDR only**]({% link {{ page.version.version }}/logical-data-replication-overview.md %}#use-cases)) Ignore [TTL deletes]({% link {{ page.version.version }}/row-level-ttl.md %}) in an LDR stream with `discard = ttl-deletes`. **Note**: To ignore row-level TTL deletes in an LDR stream, it is necessary to set the [`ttl_disable_changefeed_replication`]({% link {{ page.version.version }}/row-level-ttl.md %}#ttl-storage-parameters) storage parameter on the source table. Refer to the [Ignore row-level TTL deletes](#ignore-row-level-ttl-deletes) example.
52
52
`label` | Tracks LDR metrics at the job level. Add a user-specified string with `label`. Refer to [Metrics labels]({% link {{ page.version.version }}/logical-data-replication-monitoring.md %}#metrics-labels).
53
-
`mode` | Determines how LDR replicates the data to the destination cluster. Possible values: `immediate`, `validated`. For more details, refer to [LDR modes](#ldr-modes).
54
-
55
-
## LDR modes
56
-
57
-
_Modes_ determine how LDR replicates the data to the destination cluster. There are two modes:
58
-
59
-
-`immediate` (default): {% include {{ page.version.version }}/ldr/immediate-description.md %}
60
-
-`validated`: {% include {{ page.version.version }}/ldr/validated-description.md %}
-**Table-level replication**: When you initiate LDR, it will replicate all of the source table's existing data to the destination table. From then on, LDR will replicate the source table's data to the destination table to achieve eventual consistency.
45
45
-**Last write wins conflict resolution**: LDR uses [_last write wins (LWW)_ conflict resolution]({% link {{ page.version.version }}/manage-logical-data-replication.md %}#conflict-resolution), which will use the latest [MVCC]({% link {{ page.version.version }}/architecture/storage-layer.md %}#mvcc) timestamp to resolve a conflict in row insertion.
46
46
-**Dead letter queue (DLQ)**: When LDR starts, the job will create a [DLQ table]({% link {{ page.version.version }}/manage-logical-data-replication.md %}#dead-letter-queue-dlq) with each replicating table in order to track unresolved conflicts. You can interact and manage this table like any other SQL table.
47
-
-**Replication modes**: LDR offers different [_modes_]({% link {{ page.version.version }}/create-logical-replication-stream.md %}#ldr-modes) that apply data differently during replication, which allows you to consider optimizing for throughput or constraints during replication.
48
47
-**Monitoring**: To [monitor]({% link {{ page.version.version }}/logical-data-replication-monitoring.md %}) LDR's initial progress, current status, and performance, you can view metrics available in the DB Console, Prometheus, and Metrics Export.
Copy file name to clipboardExpand all lines: src/current/v24.3/manage-logical-data-replication.md
+3-8Lines changed: 3 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ In LDR, conflicts are detected at both the [KV]({% link {{ page.version.version
22
22
23
23
### KV level conflicts
24
24
25
-
LDR uses _last write wins (LWW)_ conflict resolution based on the [MVCC timestamp]({% link {{ page.version.version }}/architecture/storage-layer.md %}#mvcc) of the replicating write. LDR will resolve conflicts by inserting the row with the latest MVCC timestamp. Conflicts at the KV level are detected in both `immediate` and `validated` mode.
25
+
LDR uses _last write wins (LWW)_ conflict resolution based on the [MVCC timestamp]({% link {{ page.version.version }}/architecture/storage-layer.md %}#mvcc) of the replicating write. LDR will resolve conflicts by inserting the row with the latest MVCC timestamp.
26
26
27
27
Conflicts at the KV level are detected when there is either:
28
28
@@ -31,21 +31,16 @@ Conflicts at the KV level are detected when there is either:
31
31
32
32
### SQL level conflicts
33
33
34
-
In `validated` mode, when a conflict cannot apply due to violating [constraints]({% link {{ page.version.version }}/constraints.md %}), for example, a foreign key constraint or schema constraint, it will be retried for up to a minute and then put in the [DLQ](#dead-letter-queue-dlq) if it could not be resolved.
34
+
When a conflict cannot apply due to violating [constraints]({% link {{ page.version.version }}/constraints.md %}), for example, a foreign key constraint or schema constraint, LDR will send the row to the [DLQ](#dead-letter-queue-dlq).
35
35
36
36
### Dead letter queue (DLQ)
37
37
38
-
When the LDR job starts, it will create a DLQ table with each replicating table so that unresolved conflicts can be tracked. The DLQ will contain the writes that LDR cannot apply after the retry period, which could occur if:
38
+
When the LDR job starts, it will create a DLQ table with each replicating table so that unresolved conflicts can be tracked. The DLQ will contain the writes that LDR cannot apply after the retry period of a minute, which could occur if:
39
39
40
40
- The destination table was dropped.
41
41
- The destination cluster is unavailable.
42
42
- Tables schemas do not match.
43
43
44
-
In `validated` mode, rows are also sent to the DLQ when:
45
-
46
-
-[Foreign key]({% link {{ page.version.version }}/foreign-key.md %}) dependencies are not met where there are foreign key constraints in the schema.
47
-
- Unique indexes and other constraints are not met.
48
-
49
44
{{site.data.alerts.callout_info}}
50
45
LDR will not pause when the writes are sent to the DLQ, you must manage the DLQ manually.
Copy file name to clipboardExpand all lines: src/current/v24.3/set-up-logical-data-replication.md
+15-13Lines changed: 15 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ If you're setting up bidirectional LDR, both clusters will act as a source and a
22
22
23
23
1. Prepare the tables on each cluster with the prerequisites for starting LDR.
24
24
1. Set up an [external connection]({% link {{ page.version.version }}/create-external-connection.md %}) on cluster B (which will be the destination cluster initially) to hold the connection URI for cluster A.
25
-
1. Start LDR from cluster B with your required modes.
25
+
1. Start LDR from cluster B with your required options.
26
26
1. (Optional) Run Steps 1 to 3 again with cluster B as the source and A as the destination, which starts LDR streaming from cluster B to A.
27
27
1. Check the status of the LDR job in the [DB Console]({% link {{ page.version.version }}/ui-overview.md %}).
28
28
@@ -36,10 +36,6 @@ You'll need:
36
36
- All nodes in each cluster will need access to the Certificate Authority for the other cluster. Refer to [Step 2. Connect from the destination to the source](#step-2-connect-from-the-destination-to-the-source).
37
37
- LDR replicates at the table level, which means clusters can contain other tables that are not part of the LDR job. If both clusters are empty, create the tables that you need to replicate with **identical** schema definitions (excluding indexes) on both clusters. If one cluster already has an existing table that you'll replicate, ensure the other cluster's table definition matches. For more details on the supported schemas, refer to [Schema Validation](#schema-validation).
38
38
39
-
{% comment %}To add later, after further dev work{{site.data.alerts.callout_info}}
40
-
If you need to run LDR through a load balancer, use the load balancer IP address as the SQL advertise address on each cluster. It is important to note that using a load balancer with LDR can impair performance.
41
-
{{site.data.alerts.end}}{% endcomment %}
42
-
43
39
To create bidirectional LDR, you can complete the [optional step](#step-4-optional-set-up-bidirectional-ldr) to start the second LDR job that sends writes from the table on cluster B to the table on cluster A.
44
40
45
41
### Schema validation
@@ -55,7 +51,20 @@ You cannot use LDR on a table with a schema that contains the following:
55
51
56
52
For more details, refer to the LDR [Known limitations]({% link {{ page.version.version }}/logical-data-replication-overview.md %}#known-limitations).
57
53
58
-
When you run LDR in [`immediate` mode](#modes), you cannot replicate a table with [foreign key constraints]({% link {{ page.version.version }}/foreign-key.md %}). In [`validated` mode](#modes), foreign key constraints **must** match. All constraints are enforced at the time of SQL/application write.
54
+
LDR does not support replicating a table with [foreign key constraints]({% link {{ page.version.version }}/foreign-key.md %}).
55
+
56
+
#### Unique secondary indexes
57
+
58
+
In LDR, the presence of unique [secondary index]({% link {{ page.version.version }}/schema-design-indexes.md %}) constraints on the destination table can increase the likelihood of rows being sent to the [_dead letter queue_ (DLQ)]({% link {{ page.version.version }}/manage-logical-data-replication.md %}). The two clusters in LDR operate independently, so writes to one cluster can conflict with writes to the other.
59
+
60
+
If the application modifies the same row in both clusters, LDR resolves the conflict using _last write wins_ (LWW) conflict resolution. [`UNIQUE` constraints]({% link {{ page.version.version }}/unique.md %}) are validated locally in each cluster, therefore if a replicated write violates a `UNIQUE` constraint on the destination cluster—possibly because a conflicting write was already applied to the row—the replicating row will be applied to the DLQ.
61
+
62
+
For example, consider a table with a unique `email` column. If an application attempts to insert (`gen_random_uuid()`, `[email protected]`) into both clusters simultaneously, the insert will succeed in both clusters, but the records will have different [primary keys]({% link {{ page.version.version }}/primary-key.md %}). When the rows are replicated, LDR will DLQ the row in the peer cluster.
63
+
64
+
To reduce DLQ entries and allow LDR to be eventually consistent, we recommend:
65
+
66
+
- For **unidirectional** LDR, validate unique index constraints on the source cluster only.
67
+
- For **bidirectional** LDR, remove unique index constraints on both clusters.
59
68
60
69
## Step 1. Prepare the cluster
61
70
@@ -117,20 +126,13 @@ You can use the `cockroach encode-uri` command to generate a connection string c
117
126
118
127
In this step, you'll start the LDR job from the destination cluster. You can replicate one or multiple tables in a single LDR job. You cannot replicate system tables in LDR, which means that you must manually apply configurations and cluster settings, such as [row-level TTL]({% link {{ page.version.version }}/row-level-ttl.md %}) and user permissions on the destination cluster.
119
128
120
-
<a id="modes"></a>_Modes_ determine how LDR replicates the data to the destination cluster. There are two modes:
121
-
122
-
- `immediate` (default): {% include {{ page.version.version }}/ldr/immediate-description.md %}
123
-
- `validated`: {% include {{ page.version.version }}/ldr/validated-description.md %}
124
-
125
129
1. From the **destination** cluster, start LDR. Use the fully qualified table name for the source and destination tables:
126
130
127
131
{% include_cached copy-clipboard.html %}
128
132
~~~ sql
129
133
CREATE LOGICAL REPLICATION STREAM FROM TABLE {database.public.source_table_name} ON 'external://{source_external_connection}' INTO TABLE {database.public.destination_table_name};
130
134
~~~
131
135
132
-
You can change the default `mode` using the `WITH mode = validated` syntax.
133
-
134
136
If you would like to add multiple tables to the LDR job, ensure that the table name in the source table list and destination table list are in the same order:
Copy file name to clipboardExpand all lines: src/current/v25.1/create-logical-replication-stream.md
-8Lines changed: 0 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -54,14 +54,6 @@ Option | Description
54
54
`cursor` | Emits any changes after the specified timestamp. LDR will not perform an initial backfill with the `cursor` option, it will stream any changes after the specified timestamp. The LDR job will encounter an error if you specify a `cursor` timestamp that is before the configured [garbage collection]({% link {{ page.version.version }}/architecture/storage-layer.md %}#garbage-collection) window for that table. **Warning:** Apply the `cursor` option carefully to LDR streams. Using a timestamp in error could cause data loss.
55
55
<aid="discard-ttl-deletes-option"></a>`discard` | ([**Unidirectional LDR only**]({% link {{ page.version.version }}/logical-data-replication-overview.md %}#use-cases)) Ignore [TTL deletes]({% link {{ page.version.version }}/row-level-ttl.md %}) in an LDR stream with `discard = ttl-deletes`. **Note**: To ignore row-level TTL deletes in an LDR stream, it is necessary to set the [`ttl_disable_changefeed_replication`]({% link {{ page.version.version }}/row-level-ttl.md %}#ttl-storage-parameters) storage parameter on the source table. Refer to the [Ignore row-level TTL deletes](#ignore-row-level-ttl-deletes) example.
56
56
`label` | Tracks LDR metrics at the job level. Add a user-specified string with `label`. Refer to [Metrics labels]({% link {{ page.version.version }}/logical-data-replication-monitoring.md %}#metrics-labels).
57
-
`mode` | Determines how LDR replicates the data to the destination cluster. Possible values: `immediate`, `validated`. For more details, refer to [LDR modes](#ldr-modes).
58
-
59
-
## LDR modes
60
-
61
-
_Modes_ determine how LDR replicates the data to the destination cluster. There are two modes:
62
-
63
-
-`immediate` (default): {% include {{ page.version.version }}/ldr/immediate-description.md %}
64
-
-`validated`: {% include {{ page.version.version }}/ldr/validated-description.md %}
Copy file name to clipboardExpand all lines: src/current/v25.1/create-logically-replicated.md
+1-9Lines changed: 1 addition & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -55,14 +55,6 @@ Option | Description
55
55
-------+------------
56
56
`bidirectional on` / `unidirectional` | (**Required**) Specifies whether the LDR stream will be unidirectional or bidirectional. With `bidirectional on` specified, LDR will set up two LDR streams between the clusters. Refer to the examples for [unidirectional](#unidirectional) and [bidirectional](#bidirectional).
57
57
`label` | Tracks LDR metrics at the job level. Add a user-specified string with `label`. For more details, refer to [Metrics labels]({% link {{ page.version.version }}/logical-data-replication-monitoring.md %}#metrics-labels).
58
-
`mode` | Determines how LDR replicates the data to the destination cluster. Possible values: `immediate`, `validated`. For more details, refer to [LDR modes](#ldr-modes).
59
-
60
-
## LDR modes
61
-
62
-
_Modes_ determine how LDR replicates the data to the destination cluster. There are two modes:
63
-
64
-
-`immediate` (default): {% include {{ page.version.version }}/ldr/immediate-description.md %}
65
-
-`validated`: {% include {{ page.version.version }}/ldr/validated-description.md %}
66
58
67
59
## Examples
68
60
@@ -74,7 +66,7 @@ From the destination cluster of the LDR stream, run:
74
66
75
67
{% include_cached copy-clipboard.html %}
76
68
~~~sql
77
-
CREATE LOGICALLY REPLICATED TABLE {database.public.destination_table_name} FROM TABLE {database.public.source_table_name} ON'external://source' WITH unidirectional, mode=validated;
69
+
CREATE LOGICALLY REPLICATED TABLE {database.public.destination_table_name} FROM TABLE {database.public.source_table_name} ON'external://source' WITH unidirectional;
-**Table-level replication**: When you initiate LDR, it will replicate all of the source table's existing data to the destination table. From then on, LDR will replicate the source table's data to the destination table to achieve eventual consistency.
45
45
-**Last write wins conflict resolution**: LDR uses [_last write wins (LWW)_ conflict resolution]({% link {{ page.version.version }}/manage-logical-data-replication.md %}#conflict-resolution), which will use the latest [MVCC]({% link {{ page.version.version }}/architecture/storage-layer.md %}#mvcc) timestamp to resolve a conflict in row insertion.
46
46
-**Dead letter queue (DLQ)**: When LDR starts, the job will create a [DLQ table]({% link {{ page.version.version }}/manage-logical-data-replication.md %}#dead-letter-queue-dlq) with each replicating table in order to track unresolved conflicts. You can interact and manage this table like any other SQL table.
47
-
-**Replication modes**: LDR offers different [_modes_]({% link {{ page.version.version }}/create-logical-replication-stream.md %}#ldr-modes) that apply data differently during replication, which allows you to consider optimizing for throughput or constraints during replication.
48
47
-**Monitoring**: To [monitor]({% link {{ page.version.version }}/logical-data-replication-monitoring.md %}) LDR's initial progress, current status, and performance, you can view metrics available in the DB Console, Prometheus, and Metrics Export.
Copy file name to clipboardExpand all lines: src/current/v25.1/manage-logical-data-replication.md
+3-8Lines changed: 3 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ In LDR, conflicts are detected at both the [KV]({% link {{ page.version.version
22
22
23
23
### KV level conflicts
24
24
25
-
LDR uses _last write wins (LWW)_ conflict resolution based on the [MVCC timestamp]({% link {{ page.version.version }}/architecture/storage-layer.md %}#mvcc) of the replicating write. LDR will resolve conflicts by inserting the row with the latest MVCC timestamp. Conflicts at the KV level are detected in both `immediate` and `validated` mode.
25
+
LDR uses _last write wins (LWW)_ conflict resolution based on the [MVCC timestamp]({% link {{ page.version.version }}/architecture/storage-layer.md %}#mvcc) of the replicating write. LDR will resolve conflicts by inserting the row with the latest MVCC timestamp.
26
26
27
27
Conflicts at the KV level are detected when there is either:
28
28
@@ -31,21 +31,16 @@ Conflicts at the KV level are detected when there is either:
31
31
32
32
### SQL level conflicts
33
33
34
-
In `validated` mode, when a conflict cannot apply due to violating [constraints]({% link {{ page.version.version }}/constraints.md %}), for example, a foreign key constraint or schema constraint, it will be retried for up to a minute and then put in the [DLQ](#dead-letter-queue-dlq) if it could not be resolved.
34
+
When a conflict cannot apply due to violating [constraints]({% link {{ page.version.version }}/constraints.md %}), for example, a foreign key constraint or schema constraint, LDR will send the row to the [DLQ](#dead-letter-queue-dlq).
35
35
36
36
### Dead letter queue (DLQ)
37
37
38
-
When the LDR job starts, it will create a DLQ table with each replicating table so that unresolved conflicts can be tracked. The DLQ will contain the writes that LDR cannot apply after the retry period, which could occur if:
38
+
When the LDR job starts, it will create a DLQ table with each replicating table so that unresolved conflicts can be tracked. The DLQ will contain the writes that LDR cannot apply after the retry period of a minute, which could occur if:
39
39
40
40
- The destination table was dropped.
41
41
- The destination cluster is unavailable.
42
42
- Tables schemas do not match.
43
43
44
-
In `validated` mode, rows are also sent to the DLQ when:
45
-
46
-
-[Foreign key]({% link {{ page.version.version }}/foreign-key.md %}) dependencies are not met where there are foreign key constraints in the schema.
47
-
- Unique indexes and other constraints are not met.
48
-
49
44
{{site.data.alerts.callout_info}}
50
45
LDR will not pause when the writes are sent to the DLQ, you must manage the DLQ manually.
0 commit comments