-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP] Create a JDBC connection only while decoding array types #335
base: main
Are you sure you want to change the base?
Conversation
@@ -29,7 +30,7 @@ | |||
* @author Vaibhav Kushwaha ([email protected]) | |||
*/ | |||
|
|||
public class YugabyteDBDatatypesTest extends YugabyteDBContainerTestBase { | |||
public class YugabyteDBDatatypesTest extends YugabytedTestBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo Vaibhav: Revert this change before final review.
@@ -26,16 +31,17 @@ | |||
|
|||
import static org.junit.jupiter.api.Assertions.*; | |||
|
|||
public class YugabyteDBCompleteTypesTest extends YugabyteDBContainerTestBase { | |||
public class YugabyteDBCompleteTypesTest extends YugabytedTestBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo Vaibhav: Revert this change before final review.
Arguments.of(false, false), // Older stream | ||
Arguments.of(true, false)); // NO_EXPORT stream | ||
Arguments.of(false, false)); // Older stream | ||
// Arguments.of(true, false)); // NO_EXPORT stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo Vaibhav: Revert this change before final review.
8214345
to
4e492ca
Compare
src/main/java/io/debezium/connector/yugabytedb/YugabyteDBChangeEventSourceFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/io/debezium/connector/yugabytedb/YugabyteDBChangeEventSourceFactory.java
Outdated
Show resolved
Hide resolved
@@ -196,8 +196,7 @@ private Object[] columnValues(List<ReplicationMessage.Column> columns, TableId t | |||
undeliveredToastableColumns.remove(columnName); | |||
int position = getPosition(columnName, table, values); | |||
if (position != -1) { | |||
Object value = column.getValue(() -> (BaseConnection) connection.connection(), | |||
connectorConfig.includeUnknownDatatypes()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this change needed, connection.connection() can return null/connection depending on the context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The YugabyteDBConnection
object doesn't have any context of what type of data it will be used to decode. In case an array type is encountered, then a JDBC connection is created to be used otherwise it would be just the YugabyteDBConnection
object.
Problem
The
YugabyteDBConnector
opens a global JDBC connection which is used to decode data types, this connection is created only once per task and is retained for the complete lifetime of the task. However, one task per connection creates a problem when the task count is high and we end up in a state where we have a lot of JDBC connections open.Since the change events the connector receives are already decoded in case of non-array types, a JDBC connection is not really needed to decode them so unless there's an array type in the table the connector is polling, the connection keeps hogging resources.
Solution
This PR aims to change the behaviour and only uses a JDBC connection while decoding array types.