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

[DBZ-PGYB] Use YugabyteDB smart driver instead of vanilla Postgres JDBC driver #107

Merged
merged 15 commits into from
Apr 24, 2024

Conversation

vaibhav-yb
Copy link
Collaborator

@vaibhav-yb vaibhav-yb commented Mar 27, 2024

Problem

The Debezium connector for Postgres uses a single host model where the JDBC driver connects to a PG instance and continues execution. However, when we move to YugabyteDB where we have a multi node deployment, the current model can fail in case the node it has connected to goes down.

Solution

To address that, we have made changes in this PR and replaced the Postgres JDBC driver with YugabyteDB smart driver which allows us to specify multiple hosts in the JDBC url so that the connector does not fail or run into any fatal error while maintaining the High Availability aspect of YugabyteDB.

Changes in this PR include:

  1. Changing of version in pom.xml from 2.5.2.Final to 2.5.2.ybpg.20241-SNAPSHOT
    a. This is done to ensure that upon image compilation, the changed code from Debezium Code is picked up.
  2. Replacing of all packages from org.postgresql.* to com.yugabyte.* to comply with the new JDBC driver.
  3. Masking the validator method in debezium-core which disallowed characters like : (colon) in the configuration property database.hostname

@vaibhav-yb vaibhav-yb self-assigned this Mar 27, 2024
@vaibhav-yb vaibhav-yb changed the title [WIP] Use YugabyteDB smart driver instead of vanilla Postgres JDBC driver [DBZ-PGYB] Use YugabyteDB smart driver instead of vanilla Postgres JDBC driver Apr 11, 2024
@@ -1140,6 +1140,15 @@ private static int validateFlushLsnSource(Configuration config, Field field, Fie
return 0;
}

public JdbcConnection.ConnectionFactory getConnectionFactory() {
Copy link

@asrinivasanyb asrinivasanyb Apr 11, 2024

Choose a reason for hiding this comment

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

Can this be a static method. This can then be called from PostgresConnection as well (instead of duplicating the code there)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It cannot be a static method since the methods/attributes this is accessing are non-static.

@@ -85,6 +86,7 @@ public class PostgresConnection extends JdbcConnection {

private final TypeRegistry typeRegistry;
private final PostgresDefaultValueConverter defaultValueConverter;
private final JdbcConfiguration jdbcConfig;

Choose a reason for hiding this comment

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

why is this new instance variable required ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is required as we access the hostname using jdbcConfig.hostname() in the helper methods of this class.

@@ -2860,6 +2860,39 @@ public void shouldOutputRecordsInCloudEventsFormat() throws Exception {
}
}

// YB Note: Running this test also requires a change of values in the method TestHelper#defaultJdbcConfig

Choose a reason for hiding this comment

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

Could add a comment here that this test is for manual testing.
Also instructions on what to do and when

@vaibhav-yb vaibhav-yb merged commit 8c4ee44 into ybdb-debezium-2.5.2 Apr 24, 2024
@vaibhav-yb vaibhav-yb deleted the smart-driver-support branch June 3, 2024 06:21
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.

2 participants