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

Reducing JDBC SchemaDiscovery error timeout #1899

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

VardhanThigle
Copy link
Contributor

@VardhanThigle VardhanThigle commented Sep 27, 2024

Reducing MySQL SchemaDiscovery error timeout #1899

Overview

  1. The default Backoff used in sourcedb-to-spanner for MySQL connections was quite large than Dataflow's pipeline launch failure.
  2. Irrespective of the outer backoff, at the layer of jdbc connection pool, dbcp2 has an indefinite wait to acquire connections.

Fix

  1. Added loginTimeout for jdbc (this takes into fact that dbcp2 does not natively support loginTimeOut. In the most Ideal case this can be implemented at the layer of JdbcDataSource too, but, it get's tricky to limit this to only discovery layer and also tricker to unit test)
  2. The current loginTimout is limited only for discovery, as we have not faced this issue in runtime and capping run-time timeout could have un-intended side effects needed a thorough scale test. If the connectivity is not correctly configured we will any ways fail fast in the discovery layer.
  3. Added stringificaiton of JdbcDataSource for better logging.
  4. Minor logging typo fixes.

Sample Error logs

Log-1

com.google.cloud.teleport.v2.source.reader.io.jdbc.dialectadapter.mysql.MysqlDialectAdapter - Sql exception while discovering table list for datasource=JdbcDataSource: {"sourceDbURL":"jdbc:mysql://X.X.X.X:3306/test?allowMultiQueries=true&autoReconnect=true&maxReconnects=10", "initSql":"[SET TIME_ZONE = '+00:00', SET SESSION NET_WRITE_TIMEOUT=1200, SET SESSION NET_READ_TIMEOUT=1200]", "maxConnections","160" } cause=java.sql.SQLException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 10 times. Giving up.)

Log-2

com.google.cloud.teleport.v2.source.reader.io.exception.SchemaDiscoveryException: java.sql.SQLException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 10 times. Giving up.)
	at com.google.cloud.teleport.v2.source.reader.io.jdbc.dialectadapter.mysql.MysqlDialectAdapter.discoverTables(MysqlDialectAdapter.java:157)
	at com.google.cloud.teleport.v2.source.reader.io.schema.SchemaDiscoveryImpl.lambda$discoverTables$0(SchemaDiscoveryImpl.java:64)
	at com.google.cloud.teleport.v2.source.reader.io.schema.SchemaDiscoveryImpl.doRetries(SchemaDiscoveryImpl.java:114)
	at com.google.cloud.teleport.v2.source.reader.io.schema.SchemaDiscoveryImpl.discoverTables(SchemaDiscoveryImpl.java:63)
	at com.google.cloud.teleport.v2.source.reader.io.jdbc.iowrapper.JdbcIoWrapper.autoInferTableConfigs(JdbcIoWrapper.java:259)
	at com.google.cloud.teleport.v2.source.reader.io.jdbc.iowrapper.JdbcIoWrapper.of(JdbcIoWrapper.java:90)
	at com.google.cloud.teleport.v2.templates.PipelineController.executeSingleInstanceMigration(PipelineController.java:120)
	at com.google.cloud.teleport.v2.templates.SourceDbToSpanner.run(SourceDbToSpanner.java:111)
	at com.google.cloud.teleport.v2.templates.SourceDbToSpanner.main(SourceDbToSpanner.java:88)

Note

Note that Log-1 provides the host details as well as the exception, and is more relevant for debugging the connectivity issues than Log-2.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.

Project coverage is 51.54%. Comparing base (0ac9251) to head (609d14a).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...source/reader/io/jdbc/iowrapper/JdbcIoWrapper.java 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1899      +/-   ##
============================================
+ Coverage     44.60%   51.54%   +6.93%     
+ Complexity     3549     1278    -2271     
============================================
  Files           832      370     -462     
  Lines         49282    20155   -29127     
  Branches       5184     2043    -3141     
============================================
- Hits          21983    10389   -11594     
+ Misses        25654     9108   -16546     
+ Partials       1645      658     -987     
Components Coverage Δ
spanner-templates 66.24% <93.93%> (+0.86%) ⬆️
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration 74.80% <ø> (ø)
spanner-live-reverse-replication 75.50% <ø> (ø)
spanner-bulk-migration 84.32% <93.93%> (+0.04%) ⬆️
Files with missing lines Coverage Δ
...jdbc/dialectadapter/mysql/MysqlDialectAdapter.java 99.63% <ø> (ø)
...ctadapter/postgresql/PostgreSQLDialectAdapter.java 87.15% <ø> (ø)
...ource/reader/io/jdbc/iowrapper/JdbcDataSource.java 88.09% <100.00%> (+0.29%) ⬆️
.../io/jdbc/iowrapper/config/JdbcIOWrapperConfig.java 100.00% <100.00%> (ø)
...iowrapper/config/defaults/MySqlConfigDefaults.java 100.00% <100.00%> (ø)
...pper/config/defaults/PostgreSQLConfigDefaults.java 100.00% <100.00%> (ø)
...source/reader/io/jdbc/iowrapper/JdbcIoWrapper.java 93.56% <90.90%> (-0.40%) ⬇️

... and 479 files with indirect coverage changes

@VardhanThigle VardhanThigle changed the title Reducing MySQL SchemaDiscovery error timeout [DRAFT] Reducing MySQL SchemaDiscovery error timeout Sep 30, 2024
@pull-request-size pull-request-size bot added size/M and removed size/S labels Sep 30, 2024
@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 30, 2024
@VardhanThigle VardhanThigle force-pushed the fetch-size branch 3 times, most recently from e435328 to 7eea7ff Compare September 30, 2024 11:19
@VardhanThigle VardhanThigle changed the title [DRAFT] Reducing MySQL SchemaDiscovery error timeout Reducing MySQL SchemaDiscovery error timeout Sep 30, 2024
@VardhanThigle VardhanThigle marked this pull request as ready for review September 30, 2024 11:34
@VardhanThigle VardhanThigle requested a review from a team as a code owner September 30, 2024 11:34
@VardhanThigle VardhanThigle changed the title Reducing MySQL SchemaDiscovery error timeout Reducing JDBC SchemaDiscovery error timeout Sep 30, 2024
@VardhanThigle VardhanThigle force-pushed the fetch-size branch 2 times, most recently from 866f0d9 to 887e8dc Compare October 1, 2024 04:05
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 Overall. Just a minor question.

@VardhanThigle VardhanThigle force-pushed the fetch-size branch 2 times, most recently from f3bcf04 to f53e264 Compare October 1, 2024 10:29
@VardhanThigle VardhanThigle merged commit e83f8a4 into GoogleCloudPlatform:main Oct 3, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants