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

[WIP] Create a JDBC connection only while decoding array types #335

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

vaibhav-yb
Copy link
Collaborator

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.

@@ -29,7 +30,7 @@
* @author Vaibhav Kushwaha ([email protected])
*/

public class YugabyteDBDatatypesTest extends YugabyteDBContainerTestBase {
public class YugabyteDBDatatypesTest extends YugabytedTestBase {
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

@@ -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());
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

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