Skip to content

[SpannerToSourceDb] Fixing CDC events processing logic for Reverse replication template#2919

Merged
darshan-sj merged 6 commits intoGoogleCloudPlatform:mainfrom
darshan-sj:rr-cdc-fix
Oct 28, 2025
Merged

[SpannerToSourceDb] Fixing CDC events processing logic for Reverse replication template#2919
darshan-sj merged 6 commits intoGoogleCloudPlatform:mainfrom
darshan-sj:rr-cdc-fix

Conversation

@darshan-sj
Copy link
Contributor

@darshan-sj darshan-sj commented Oct 24, 2025

Fixing the CDC event processing logic in Reverse replication template

@darshan-sj darshan-sj requested a review from a team as a code owner October 24, 2025 06:08
@gemini-code-assist
Copy link

Summary of Changes

Hello @darshan-sj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces foundational changes to support a 'Double transaction flow implementation' by refactoring core utility classes and enhancing data access object (DAO) interfaces. It centralizes Spanner read utilities, expands transactional capabilities across different database DAOs, and enables the generation of SQL statements for exclusive row locking, which are crucial for robust event processing logic.

Highlights

  • Refactoring Spanner Read Utilities: The ShadowTableReadUtils class has been renamed to SpannerReadUtils and moved from datastream-to-spanner to the more general spanner-common module to promote reusability. All existing references in ChangeEventContext, MySqlChangeEventSequence, OracleChangeEventSequence, PostgresChangeEventSequence, and its corresponding test class have been updated accordingly.
  • Enhanced IDao Interface for Transactional Operations: The IDao interface has been made generic to support a ConnectionT type for transaction contexts. New methods executeRead, write(ConnectionT, T), getConnection, commit, and close have been added to facilitate explicit transactional control.
  • DAO Implementations Updated: Both CassandraDao and JdbcDao have been updated to implement the new generic IDao interface. JdbcDao now fully supports the new transactional methods, while CassandraDao provides UnsupportedOperationException for these methods as they are not applicable.
  • SpannerDao and DML Generator Updates: The SpannerDao now includes a readShadowTableRecordWithExclusiveLock method, utilizing the newly refactored SpannerReadUtils. The IDMLGenerator interface has been extended with generateReadStatementWithExclusiveLock, which MySQLDMLGenerator implements to produce SELECT ... FOR UPDATE statements for exclusive row locking.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@darshan-sj darshan-sj added the improvement Making existing code better label Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 54.11765% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.03%. Comparing base (69c5649) to head (5523641).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...leport/v2/templates/transforms/SourceWriterFn.java 75.51% 6 Missing and 6 partials ⚠️
...t/v2/templates/dbutils/dao/spanner/SpannerDao.java 8.33% 11 Missing ⚠️
...teleport/v2/templates/utils/ShadowTableRecord.java 0.00% 6 Missing ⚠️
...cloud/teleport/v2/templates/SpannerToSourceDb.java 0.00% 3 Missing ⚠️
.../v2/templates/dbutils/dao/source/CassandraDao.java 0.00% 1 Missing and 1 partial ⚠️
...eport/v2/templates/dbutils/dao/source/JdbcDao.java 60.00% 1 Missing and 1 partial ⚠️
...2/spanner/migrations/spanner/SpannerReadUtils.java 0.00% 1 Missing ⚠️
...plates/dbutils/processor/InputRecordProcessor.java 50.00% 1 Missing ⚠️
...v2/templates/transforms/SourceWriterTransform.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2919      +/-   ##
============================================
- Coverage     50.06%   50.03%   -0.04%     
- Complexity     4971     4977       +6     
============================================
  Files           967      967              
  Lines         59320    59372      +52     
  Branches       6447     6457      +10     
============================================
+ Hits          29700    29708       +8     
- Misses        27516    27554      +38     
- Partials       2104     2110       +6     
Components Coverage Δ
spanner-templates 70.39% <54.11%> (-0.10%) ⬇️
spanner-import-export 69.07% <ø> (-0.02%) ⬇️
spanner-live-forward-migration 79.69% <80.00%> (ø)
spanner-live-reverse-replication 77.12% <51.85%> (-0.31%) ⬇️
spanner-bulk-migration 88.22% <0.00%> (+0.01%) ⬆️
Files with missing lines Coverage Δ
...rt/v2/templates/datastream/ChangeEventContext.java 92.85% <100.00%> (ø)
...templates/datastream/MySqlChangeEventSequence.java 84.37% <100.00%> (ø)
...emplates/datastream/OracleChangeEventSequence.java 80.95% <100.00%> (ø)
...plates/datastream/PostgresChangeEventSequence.java 84.31% <100.00%> (ø)
...2/spanner/migrations/spanner/SpannerReadUtils.java 91.66% <0.00%> (ø)
...plates/dbutils/processor/InputRecordProcessor.java 86.44% <50.00%> (ø)
...v2/templates/transforms/SourceWriterTransform.java 0.00% <0.00%> (ø)
.../v2/templates/dbutils/dao/source/CassandraDao.java 91.30% <0.00%> (-8.70%) ⬇️
...eport/v2/templates/dbutils/dao/source/JdbcDao.java 90.90% <60.00%> (-9.10%) ⬇️
...cloud/teleport/v2/templates/SpannerToSourceDb.java 0.00% <0.00%> (ø)
... and 3 more

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@darshan-sj darshan-sj changed the title [SpannerToSourceDb] Fixing events processing logic - 1 [SpannerToSourceDb] Fixing CDC events processing logic for Reverse replication template Oct 24, 2025
Copy link
Contributor

@bharadwaj-aditya bharadwaj-aditya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@bharadwaj-aditya bharadwaj-aditya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@darshan-sj darshan-sj merged commit 677835c into GoogleCloudPlatform:main Oct 28, 2025
40 of 42 checks passed
aasthabharill pushed a commit that referenced this pull request Dec 10, 2025
…plication template (#2919)

* Fixing the CDC event processing logic in Reverse replication template

* Addressing comments:

* Correcting unit tests

* Addressing comments and corrected tests

* Correcting shadow table read

* Correcting NPE bug:
MnkyGns pushed a commit to MnkyGns/DataflowTemplates that referenced this pull request Feb 12, 2026
…plication template (GoogleCloudPlatform#2919)

* Fixing the CDC event processing logic in Reverse replication template

* Addressing comments:

* Correcting unit tests

* Addressing comments and corrected tests

* Correcting shadow table read

* Correcting NPE bug:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Making existing code better size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants