Skip to content

Commit

Permalink
Merge pull request #349 from NitorCreations/add-option-to-disable-bat…
Browse files Browse the repository at this point in the history
…ch-updates

Add nflow.db.disable_batch_updates, default to false
  • Loading branch information
ttiurani committed Nov 15, 2019
2 parents 28fac26 + b45fa01 commit a23d8dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Add Kotlin example using nFlow with Spring Boot, and integrated nFlow Explorer
- Expose wakeup via REST-API
- Update database indices to match workflow instance polling code
- Add new configuration option `nflow.db.disable_batch_updates`

**Details**
- `nflow-engine`
Expand All @@ -19,6 +20,7 @@
- Update database indices to match current workflow instance polling code.
- Create indices for foreign keys in MS SQL database.
- Fix create database scripts to work with empty database.
- Add `nflow.db.disable_batch_updates` (default `false`) configuration parameter to make it possible to force use of multiple updates even if batch updates are supported by the database.
- Dependency updates:
- reactor.netty 0.9.1.RELEASE
- jackson 2.10.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class WorkflowInstanceDao {
private final long workflowInstanceQueryMaxResultsDefault;
private final long workflowInstanceQueryMaxActions;
private final long workflowInstanceQueryMaxActionsDefault;
private final boolean disableBatchUpdates;
int instanceStateTextLength;
int actionStateTextLength;

Expand Down Expand Up @@ -125,6 +126,10 @@ public WorkflowInstanceDao(SQLVariants sqlVariants,
workflowInstanceQueryMaxActions = env.getRequiredProperty("nflow.workflow.instance.query.max.actions", Long.class);
workflowInstanceQueryMaxActionsDefault = env.getRequiredProperty("nflow.workflow.instance.query.max.actions.default",
Long.class);
disableBatchUpdates = env.getRequiredProperty("nflow.db.disable_batch_updates", Boolean.class);
if (disableBatchUpdates) {
logger.info("nFlow DB batch updates are disabled (system property nflow.db.disable_batch_updates=true)");
}
// In one deployment, FirstColumnLengthExtractor returned 0 column length (H2), so allow explicit length setting.
instanceStateTextLength = env.getProperty("nflow.workflow.instance.state.text.length", Integer.class, -1);
actionStateTextLength = env.getProperty("nflow.workflow.action.state.text.length", Integer.class, -1);
Expand Down Expand Up @@ -181,6 +186,10 @@ private int insertWorkflowInstanceWithCte(WorkflowInstance instance) {
}
}

private boolean useBatchUpdate() {
return !disableBatchUpdates && sqlVariants.useBatchUpdate();
}

String insertWorkflowInstanceSql() {
return "insert into nflow_workflow(type, root_workflow_id, parent_workflow_id, parent_action_id, business_key, external_id, "
+ "executor_group, status, state, state_text, next_activation, workflow_signal) values (?, ?, ?, ?, ?, ?, ?, "
Expand Down Expand Up @@ -232,7 +241,7 @@ void insertVariables(final int id, final int actionId, Map<String, String> chang
if (changedStateVariables.isEmpty()) {
return;
}
if (sqlVariants.useBatchUpdate()) {
if (useBatchUpdate()) {
insertVariablesWithBatchUpdate(id, actionId, changedStateVariables);
} else {
insertVariablesWithMultipleUpdates(id, actionId, changedStateVariables);
Expand Down Expand Up @@ -538,7 +547,7 @@ public List<Integer> doInTransaction(TransactionStatus transactionStatus) {
}
sort(instances);
List<Integer> ids = new ArrayList<>(instances.size());
if (sqlVariants.useBatchUpdate()) {
if (useBatchUpdate()) {
updateNextWorkflowInstancesWithBatchUpdate(instances, ids);
} else {
updateNextWorkflowInstancesWithMultipleUpdates(instances, ids);
Expand Down
1 change: 1 addition & 0 deletions nflow-engine/src/main/resources/nflow-engine.properties
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ nflow.db.oracle.password=nflow
nflow.db.max_pool_size=4
nflow.db.idle_timeout_seconds=600
nflow.db.create_on_startup=true
nflow.db.disable_batch_updates=false

nflow.definition.persist=true
1 change: 1 addition & 0 deletions nflow-engine/src/test/resources/junit.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ nflow.db.h2.password=
nflow.db.max_pool_size=20
nflow.db.idle_timeout_seconds=600
nflow.db.create_on_startup=true
nflow.db.disable_batch_updates=false

0 comments on commit a23d8dc

Please sign in to comment.