- Google Cloud Spanner Documentation: https://cloud.google.com/spanner/docs
- Spanner Change Streams Overview: https://cloud.google.com/spanner/docs/change-streams
- Debezium Spanner Connector Reference: https://debezium.io/documentation/reference/connectors/spanner.html
Core Functionality
- Change Stream Capture: Reads database mutations (inserts, updates, deletes) from Spanner in near real time.
- Table-Level Granularity: Optionally capture changes from all tables or a defined subset.
- Transactional Consistency: Reflects Spanner’s globally consistent commit order.
- Service Account Authentication: Secure access to Spanner APIs using IAM credentials.
- Kafka Integration: Publishes change events to configured Condense Kafka topics for downstream analytics or transformations.
- Setup in GCP
- A Spanner instance and database are created.
- A Change Stream is defined (either for all tables or specific tables).
- A Google Cloud Service Account with
roles/spanner.databaseReaderaccess is generated.
- Connector Configuration in Condense
- Credentials (Service Account JSON) and connection identifiers are provided.
- Condense establishes a secure connection to Spanner.
- CDC Event Stream
- Debezium’s Spanner connector reads changes from Spanner’s Change Stream API.
- Events are parsed and serialized into JSON.
- Publish to Kafka Topics
- Condense automatically creates output topics using a prefix-based convention (
{topic.prefix}.{table_name}). - Each table change event (insert/update/delete) is delivered to the corresponding Kafka topic.
- Condense automatically creates output topics using a prefix-based convention (
Field-by-Field Explanation
1. Title
Description: Unique name to identify the Spanner CDC connector in Condense.
Example:
Spanner_CDC_Production
2. GCP Project ID
Description: ID of your Google Cloud Project where the Spanner instance resides.
Example: prj-condense-prod
3. Spanner Instance ID
Description: Name of the Google Cloud Spanner instance.
Example: condense-connector-instance
4. Spanner Database ID
Description: Database name within the Spanner instance.
Example: condense_db
5. Change Stream Name
Description: Name of the change stream configured in Spanner.
Example: change_stream_all
6. Service Account JSON
Description: JSON credentials for the service account with spanner.databaseReader permissions.
How to Obtain:
users,orders,transactions
8. Topic Prefix
Description: Prefix for automatically generated Kafka topics.
Example: spanner-cdc
9. Topic (Output)
Description: The Kafka topic in Condense where the captured CDC events are published.
Example: spanner-cdc-events
Example Topic Mapping
Event Format
Each record published to Kafka includes a before and after payload, representing state changes, along with metadata.
op: Operation type (c= create,u= update,d= delete).commit_timestamp: Exact time the change was committed in Spanner.table: Table name of the event origin.
spanner.databaseReader).
2. Change Stream Not Found
Verify the change stream exists and is active:
- Change stream may not include specific tables.
- Retention period expired.
- Verify
tables.include.listconfiguration.
- Change Stream Retention: Default retention is 7 days. Adjust via:
- Scaling: Increase Spanner processing units or connector tasks for large data volumes.
- Partition Parallelism: Connector scales with the number of change stream partitions.
- Security: Use a dedicated service account with minimal permissions and rotate keys periodically.
- Use specific
tables.include.listfor optimized performance. - Monitor
MillisecondsBehindMastermetric for replication lag. - Set a descriptive
topic.prefixfor environment separation. - Always validate change stream health before deploying.