diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java index 1526b2ac53..2254225103 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java @@ -121,6 +121,7 @@ private ParameterConstants() { public final static String DATA_LOADER_NUM_OF_ACK_RETRIES = "num.of.ack.retries"; public final static String DATA_LOADER_TIME_BETWEEN_ACK_RETRIES = "time.between.ack.retries.ms"; public final static String DATA_LOADER_MAX_ROWS_BEFORE_COMMIT = "dataloader.max.rows.before.commit"; + public final static String DATA_LOADER_SLEEP_TIME_AFTER_EARLY_COMMIT = "dataloader.sleep.time.after.early.commit"; public final static String DATA_LOADER_TREAT_DATETIME_AS_VARCHAR = "db.treat.date.time.as.varchar.enabled"; public final static String DATA_RELOAD_IS_BATCH_INSERT_TRANSACTIONAL = "datareload.batch.insert.transactional"; diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/load/DefaultDataLoaderFactory.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/load/DefaultDataLoaderFactory.java index 908af267dc..95b11c4378 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/load/DefaultDataLoaderFactory.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/load/DefaultDataLoaderFactory.java @@ -84,6 +84,7 @@ protected DatabaseWriterSettings buildDatabaseWriterSettings( settings.setDatabaseWriterErrorHandlers(errorHandlers); settings.setMaxRowsBeforeCommit(parameterService .getLong(ParameterConstants.DATA_LOADER_MAX_ROWS_BEFORE_COMMIT)); + settings.setCommitSleepInterval(parameterService.getLong(ParameterConstants.DATA_LOADER_SLEEP_TIME_AFTER_EARLY_COMMIT)); settings.setIgnoreMissingTables(parameterService.is(ParameterConstants.DATA_LOADER_IGNORE_MISSING_TABLES)); settings.setTreatDateTimeFieldsAsVarchar(parameterService .is(ParameterConstants.DATA_LOADER_TREAT_DATETIME_AS_VARCHAR)); diff --git a/symmetric-core/src/main/resources/symmetric-default.properties b/symmetric-core/src/main/resources/symmetric-default.properties index 6d7f658a0a..c076432991 100644 --- a/symmetric-core/src/main/resources/symmetric-default.properties +++ b/symmetric-core/src/main/resources/symmetric-default.properties @@ -740,6 +740,13 @@ dataloader.ignore.missing.tables=true # Tags: load dataloader.max.rows.before.commit=10000 +# Amount of time to sleep before continuing data load after dataloader.max.rows.before.commit rows have been loaded. +# This is useful to give other application threads a chance to do work before continuing to load. +# +# DatabaseOverridable: true +# Tags: load +dataloader.sleep.time.after.early.commit=5 + # The number of milliseconds parameters will be cached by the ParameterService before they are reread from the # file system and database. # diff --git a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriter.java b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriter.java index ec2d86829e..5a9533bb02 100644 --- a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriter.java +++ b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriter.java @@ -221,16 +221,21 @@ public void write(CsvData data) { protected void checkForEarlyCommit() { if (uncommittedCount >= writerSettings.getMaxRowsBeforeCommit()) { commit(true); - /* - * Chances are if SymmetricDS is configured to commit early in a - * batch we want to give other threads a chance to do work and - * access the database. This was added to support H2 clients - * that are loading big batches while an application is doing work. - */ - try { - Thread.sleep(writerSettings.getCommitSleepInterval()); - } catch (InterruptedException e) { - log.warn("{}", e.getMessage()); + + long sleep = writerSettings.getCommitSleepInterval(); + if (sleep > 0) { + /* + * Chances are if SymmetricDS is configured to commit early in a + * batch we want to give other threads a chance to do work and + * access the database. This was added to support H2 clients + * that are loading big batches while an application is doing + * work. + */ + try { + Thread.sleep(sleep); + } catch (InterruptedException e) { + log.warn("{}", e.getMessage()); + } } } } diff --git a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriterSettings.java b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriterSettings.java index b41cdd2acd..2a16fb755d 100644 --- a/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriterSettings.java +++ b/symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DatabaseWriterSettings.java @@ -33,7 +33,7 @@ public class DatabaseWriterSettings { protected long maxRowsBeforeCommit = 10000; // Milliseconds to sleep between commits. - protected int commitSleepInterval = 5; + protected long commitSleepInterval = 5; protected boolean treatDateTimeFieldsAsVarchar = false; @@ -235,11 +235,11 @@ public Conflict pickConflict(Table table, Batch batch) { } - public int getCommitSleepInterval() { + public long getCommitSleepInterval() { return commitSleepInterval; } - public void setCommitSleepInterval(int commitSleepInterval) { + public void setCommitSleepInterval(long commitSleepInterval) { this.commitSleepInterval = commitSleepInterval; }