Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add snapshot support to logrepl mode #141

Merged
merged 11 commits into from
May 15, 2024
Merged

Add snapshot support to logrepl mode #141

merged 11 commits into from
May 15, 2024

Conversation

lyuboxa
Copy link
Contributor

@lyuboxa lyuboxa commented May 6, 2024

Description

The new combined iterator integrates snapshots with the existing cdc iterator.
Once the snapshot is completed, it will swithc to cdc.

When using snapshots, the connector will run both cdc and snapshot at the same time.
This is required because the cdc iterator needs to be initialized and export a consistent
snapshot which is taken at the time of the slot creation. The cdc iteator will need to
keep the connection open until the snapshot is done.

The switch to the cdc iterator is triggered when the snapshot returns an end of records error.
Based on this signal, the cdc subscriber will be started to consume changes from the replication slot.

Fixes #15

Quick checks:

  • I have followed the Code Guidelines.
  • There is no other pull request for the same update/change.
  • I have written unit tests.
  • I have made sure that the PR is of reasonable size and can be easily reviewed.

Copy link
Contributor

@hariso hariso left a comment

Choose a reason for hiding this comment

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

Great work, Lyu!

source/logrepl/cdc.go Outdated Show resolved Hide resolved
source/logrepl/internal/subscription_test.go Outdated Show resolved Hide resolved
source/logrepl/cdc.go Show resolved Hide resolved
source/logrepl/cdc.go Outdated Show resolved Hide resolved
source/logrepl/combined_test.go Outdated Show resolved Hide resolved
source/logrepl/combined.go Outdated Show resolved Hide resolved
source/logrepl/combined.go Outdated Show resolved Hide resolved
source/logrepl/combined.go Show resolved Hide resolved
source/logrepl/internal/subscription.go Show resolved Hide resolved
source/logrepl/combined.go Outdated Show resolved Hide resolved
source/logrepl/cdc.go Show resolved Hide resolved
source/logrepl/combined.go Outdated Show resolved Hide resolved
source/logrepl/combined.go Show resolved Hide resolved
@lyuboxa lyuboxa changed the title Combined iterator for logrepl Snapshots with CDC mode switch May 10, 2024
@lyuboxa lyuboxa changed the title Snapshots with CDC mode switch Add snapshot support to logrepl mode May 10, 2024
@lyuboxa lyuboxa marked this pull request as ready for review May 10, 2024 04:52
@lyuboxa lyuboxa requested a review from a team as a code owner May 10, 2024 04:53
source/logrepl/cdc.go Outdated Show resolved Hide resolved
The new combined iterator integrates snapshots with the existing cdc iterator.
Once the snapshot is completed, it will swithc to cdc.

When using snapshots, the connector will run both cdc and snapshot at the same time.
This is required because the cdc iterator needs to be initialized and export a consistent
snapshot which is taken at the time of the slot creation. The cdc iteator will need to
keep the connection open until the snapshot is done.

The switch to the cdc iterator is triggered when the snapshot returns an end of records error.
Based on this signal, the cdc subscriber will be started to consume changes from the replication slot.
Copy link
Contributor

@hariso hariso left a comment

Choose a reason for hiding this comment

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

LGTM! I left a couple of non-blockers. Great work, Lyubo!

source/logrepl/cleaner.go Outdated Show resolved Hide resolved
source/logrepl/internal/publication_test.go Show resolved Hide resolved
source/logrepl/internal/subscription.go Outdated Show resolved Hide resolved
test/helper.go Outdated Show resolved Hide resolved
lyuboxa and others added 4 commits May 14, 2024 15:28
Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>
Co-authored-by: Lovro Mažgon <lovro.mazgon@gmail.com>
Copy link
Member

@lovromazgon lovromazgon left a comment

Choose a reason for hiding this comment

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

Looks good, I added one last suggestion. Good work 👍

source/logrepl/cdc.go Outdated Show resolved Hide resolved
@lyuboxa lyuboxa merged commit 8cb9366 into main May 15, 2024
3 checks passed
@lyuboxa lyuboxa deleted the lk/cdc-snapshot-iterator branch May 15, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snapshot support in logrepl mode
3 participants