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

Support settable value of socket timeout in mysql #193

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions embulk-output-mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ MySQL output plugin for Embulk loads records to MySQL.
- **timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp value into a SQL string. In this cases, this timezone option is used to control the timezone. (string, value of default_timezone option is used by default)
- **before_load**: if set, this SQL will be executed before loading all records. In truncate_insert mode, the SQL will be executed after truncating. replace mode doesn't support this option.
- **after_load**: if set, this SQL will be executed after loading all records.
- **socket_timeout**: socket timeout milliseconds (string, default: "2700000")
- **retryable_socket_timeout**: socket timeout milliseconds on retrying (string, default: "1800000")

### Modes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public interface MySQLPluginTask
@ConfigDefault("\"disable\"") // backward compatibility
public Ssl getSsl();

@Config("socket_timeout")
@ConfigDefault("2700000")
public int getSocketTimeout();

@Config("retryable_socket_timeout")
@ConfigDefault("1800000")
public int getRetryableSocketTimeout();
}

@Override
Expand Down Expand Up @@ -80,7 +87,7 @@ protected MySQLOutputConnector getConnector(PluginTask task, boolean retryableMe
props.setProperty("useCompression", "true");

props.setProperty("connectTimeout", "300000"); // milliseconds
props.setProperty("socketTimeout", "1800000"); // smillieconds
props.setProperty("socketTimeout", String.valueOf(t.getRetryableSocketTimeout()));

// Enable keepalive based on tcp_keepalive_time, tcp_keepalive_intvl and tcp_keepalive_probes kernel parameters.
// Socket options TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL are not configurable.
Expand All @@ -105,7 +112,7 @@ protected MySQLOutputConnector getConnector(PluginTask task, boolean retryableMe
if (!retryableMetadataOperation) {
// non-retryable batch operation uses longer timeout
props.setProperty("connectTimeout", "300000"); // milliseconds
props.setProperty("socketTimeout", "2700000"); // milliseconds
props.setProperty("socketTimeout", String.valueOf(t.getSocketTimeout()));
}

props.putAll(t.getOptions());
Expand Down