Change Data Capture
Overview
cdc=true (either when creating the table or altering it). Upon CommitLogSegment creation, a hard-link to the segment is created in the directory specified in cassandra.yaml. On segment fsync to disk, if CDC data is present anywhere in the segment a
Configuration
Enabling or disabling CDC on a table
CDC is enable or disable through the cdc table property, for instance:
CREATE TABLE foo (a int, b text, PRIMARY KEY(a)) WITH cdc=true;ALTER TABLE foo WITH cdc=true;ALTER TABLE foo WITH cdc=false;
cassandra.yaml parameters
The following cassandra.yaml options are available for CDC:
cdc_enabled (default: false)
Enable or disable CDC operations node-wide.
cdc_raw_directory (default: $CASSANDRA_HOME/data/cdc_raw)
Destination for CommitLogSegments to be moved after all corresponding memtables are flushed.
cdc_total_space: (default: min of 4096MiB and 1/8th volume space)
all flushed CDC segments in cdc_raw_directory.
cdc_free_space_check_interval (default: 250ms)
cdc_raw_directory to prevent burning CPU cycles unnecessarily. Default is to check 4 times per second.
Reading CommitLogSegments
CommitLogReader.java. Usage is fairly straightforward with a variety of signatures available for use. In order to handle mutations read from disk, implement CommitLogReadHandler.
Warnings
Do not enable CDC without some kind of consumption process in-place.
cdc_free_space_in_mb will fill up and then writes to CDC-enabled tables will be rejected unless some consumption process is in place.
Further Reading
- JIRA ticket
- JIRA ticket
