You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2020/12/18 03:38:12 UTC
[shardingsphere] branch master updated: Optimize JDBC Importer try
flush (#8681)
This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 5308d7d Optimize JDBC Importer try flush (#8681)
5308d7d is described below
commit 5308d7d2394ec4d818c05b97311bcc6c03c41a91
Author: 邱鹿 Lucas <lu...@163.com>
AuthorDate: Fri Dec 18 11:37:57 2020 +0800
Optimize JDBC Importer try flush (#8681)
* Optimize JDBC Importer try flush.
* Optimize JDBC Importer try flush.
Co-authored-by: qiulu3 <Lucas209910>
---
.../core/execute/executor/importer/AbstractJDBCImporter.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporter.java b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporter.java
index 13afe4f..62310f9 100755
--- a/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporter.java
+++ b/shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporter.java
@@ -33,6 +33,7 @@ import org.apache.shardingsphere.scaling.core.execute.executor.record.GroupedDat
import org.apache.shardingsphere.scaling.core.execute.executor.record.Record;
import org.apache.shardingsphere.scaling.core.execute.executor.record.RecordUtil;
import org.apache.shardingsphere.scaling.core.execute.executor.sqlbuilder.ScalingSQLBuilder;
+import org.apache.shardingsphere.scaling.core.utils.ThreadUtil;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -121,15 +122,15 @@ public abstract class AbstractJDBCImporter extends AbstractScalingExecutor imple
}
private boolean tryFlush(final DataSource dataSource, final List<DataRecord> buffer) {
- int retryTimes = importerConfig.getRetryTimes();
- do {
+ for (int i = 0; isRunning() && i <= importerConfig.getRetryTimes(); i++) {
try {
doFlush(dataSource, buffer);
return true;
} catch (final SQLException ex) {
- log.error("flush failed: ", ex);
+ log.error("flush failed {}/{} times.", i, importerConfig.getRetryTimes(), ex);
+ ThreadUtil.sleep(Math.min(5 * 60 * 1000L, 1000 << i));
}
- } while (isRunning() && retryTimes-- > 0);
+ }
return false;
}