Skip to content

Commit aac237a

Browse files
author
lhirata
authored
Merge pull request cockroachdb#3418 from cockroachdb/cdc
CDC Updates
2 parents f7d2fa4 + 16c334b commit aac237a

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

v2.1/change-data-capture.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ The core feature of CDC is the [changefeed](create-changefeed.html). Changefeeds
3131

3232
- The `WITH timestamps` option adds an **update timestamp** to each emitted row. It also causes periodic **resolved timestamp** messages to be emitted to each Kafka partition. A resolved timestamp is a guarantee that no (previously unseen) rows with a lower update timestamp will be emitted on that partition.
3333

34+
For example:
35+
36+
~~~ json
37+
{"__crdb__": {"updated": "1532377312562986715.0000000000"}, "id": 1, "name": "Petee H"}
38+
{"__crdb__": {"updated": "1532377306108205142.0000000000"}, "id": 2, "name": "Carl"}
39+
{"__crdb__": {"updated": "1532377358501715562.0000000000"}, "id": 3, "name": "Ernie"}
40+
{"__crdb__":{"resolved":"1532379887442299001.0000000000"}}
41+
{"__crdb__":{"resolved":"1532379888444290910.0000000000"}}
42+
{"__crdb__":{"resolved":"1532379889448662988.0000000000"}}
43+
...
44+
{"__crdb__":{"resolved":"1532379922512859361.0000000000"}}
45+
{"__crdb__": {"updated": "1532379923319195777.0000000000"}, "id": 4, "name": "Lucky"}
46+
~~~
47+
3448
- Cross-row and cross-table order guarantees are not directly given. However, the resolved timestamp notifications on every Kafka partition can be used to provide strong ordering and global consistency guarantees by buffering records in between timestamp closures.
3549

3650
Because CockroachDB supports transactions that can affect any part of the cluster, there is no way to horizontally divide the cluster's transaction log in a way where each piece is independent, so it can't be scaled in the general case.
@@ -94,7 +108,7 @@ In this example, you'll set up a changefeed for a single-node cluster that is co
94108
$ ./cockroach start --insecure
95109
~~~
96110

97-
2. Download and extract the [Confluent platform](https://www.confluent.io/download/) (which includes Kafka).
111+
2. Download and extract the [Confluent Open Source platform](https://www.confluent.io/download/) (which includes Kafka).
98112

99113
3. Start Confluent:
100114

@@ -105,28 +119,39 @@ In this example, you'll set up a changefeed for a single-node cluster that is co
105119

106120
Only `zookeeper` and `kafka` are needed. To troubleshoot Confluent, see [their docs](https://docs.confluent.io/current/installation/installing_cp.html#zip-and-tar-archives).
107121

108-
4. As the `root` user, open the [built-in SQL client](use-the-built-in-sql-client.html):
122+
4. Create a Kafka topic:
123+
124+
{% include copy-clipboard.html %}
125+
~~~
126+
$ ./confluent-4.0.0/bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic office_dogs
127+
~~~
128+
129+
{{site.data.alerts.callout_info}}
130+
You are expected to create any Kafka topics with the necessary number of replications and partitions. [Topics can be created manually](https://kafka.apache.org/documentation/#basic_ops_add_topic) or [Kafka brokers can be configured to automatically create topics](https://kafka.apache.org/documentation/#topicconfigs) with a default partition count and replication factor.
131+
{{site.data.alerts.end}}
132+
133+
5. As the `root` user, open the [built-in SQL client](use-the-built-in-sql-client.html):
109134

110135
{% include copy-clipboard.html %}
111136
~~~ shell
112137
$ cockroach sql --insecure
113138
~~~
114139

115-
5. Create a database called `test`:
140+
6. Create a database called `test`:
116141

117142
{% include copy-clipboard.html %}
118143
~~~ sql
119144
> CREATE DATABASE cdc_demo;
120145
~~~
121146

122-
6. Set the database as the default:
147+
7. Set the database as the default:
123148

124149
{% include copy-clipboard.html %}
125150
~~~ sql
126151
> SET DATABASE = cdc_demo;
127152
~~~
128153

129-
7. Create a table and add data:
154+
8. Create a table and add data:
130155

131156
{% include copy-clipboard.html %}
132157
~~~ sql
@@ -147,7 +172,7 @@ In this example, you'll set up a changefeed for a single-node cluster that is co
147172
> UPDATE office_dogs SET name = 'Petee H' WHERE id = 1;
148173
~~~
149174

150-
8. Start the changefeed:
175+
9. Start the changefeed:
151176

152177
{% include copy-clipboard.html %}
153178
~~~ sql
@@ -164,7 +189,7 @@ In this example, you'll set up a changefeed for a single-node cluster that is co
164189

165190
This will start up the changefeed in the background and return the `job_id`. The changefeed writes to Kafka.
166191

167-
9. In a new terminal, start watching the Kafka topic:
192+
10. In a new terminal, start watching the Kafka topic:
168193

169194
{% include copy-clipboard.html %}
170195
~~~ shell
@@ -177,22 +202,22 @@ In this example, you'll set up a changefeed for a single-node cluster that is co
177202

178203
Note that the initial scan displays the state of the table as of when the changefeed started (therefore, the initial value of `"Petee"` is missing).
179204

180-
10. Back in the SQL client, insert more data:
205+
11. Back in the SQL client, insert more data:
181206

182207
{% include copy-clipboard.html %}
183208
~~~ sql
184209
> INSERT INTO office_dogs VALUES (3, 'Ernie');
185210
~~~
186211

187-
11. Back in the terminal where you're watching the Kafka topic, the following output has appeared:
212+
12. Back in the terminal where you're watching the Kafka topic, the following output has appeared:
188213
189214
~~~
190215
{"id": 3, "name": "Ernie"}
191216
~~~
192217
193218
## Known limitations
194219
195-
The following are limitations in July 2, 2018 alpha release, and will be addressed before the v2.1 release.
220+
The following are limitations in the July 30, 2018 alpha release, and will be addressed before the v2.1 release.
196221
197222
- Changefeeds created with the alpha may not be compatible with future alphas and the final v2.1 release.
198223
@@ -201,7 +226,6 @@ The following are limitations in July 2, 2018 alpha release, and will be address
201226
{{site.data.alerts.end}}
202227
203228
- The CockroachDB core changefeed is not ready for external testing.
204-
- Some intermediate updates on frequently changed rows are never emitted.
205229
- Changefeed progress is not exposed to the user.
206230
- The SQL interface is not final and may change.
207231
- Changefeeds only work on tables with a single [column family](column-families.html) (which is the default for new tables).

0 commit comments

Comments
 (0)