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

add index for polling #343

Merged
merged 4 commits into from
Nov 14, 2019
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
- Add MariaDB support
- 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

**Details**
- `nflow-engine`
- Separate workflow definition scanning from `WorkflowDefinitionService` by introducing `WorkflowDefinitionSpringBeanScanner` and `WorkflowDefinitionClassNameScanner`. This allows breaking the circular dependency when a workflow definition uses `WorkflowInstanceService` (which depends on `WorkflowDefinitionService`, which depended on all workflow definitions). This enabled using constructor injection in all nFlow classes.
- Add `disableMariaDbDriver` to default MySQL JDBC URL so that in case there are both MySQL and MariaDB JDBC drivers in the classpath then MariaDB will not steal the MySQL URL.
- Add support for `nflow.db.mariadb` profile.
- 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.
- Dependency updates:
- reactor.netty 0.8.11.RELEASE
- jackson 2.9.10
Expand Down
2 changes: 2 additions & 0 deletions nflow-engine/src/main/resources/scripts/db/db2.create.ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ create or replace trigger nflow_workflow_update_modified
drop index nflow_workflow_activation;
create index nflow_workflow_activation on nflow_workflow(next_activation, modified);

create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

create table nflow_workflow_action (
id int primary key generated always as identity,
workflow_id int not null,
Expand Down
2 changes: 2 additions & 0 deletions nflow-engine/src/main/resources/scripts/db/h2.create.ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ create unique index if not exists nflow_workflow_uniq on nflow_workflow (type, e

create index if not exists nflow_workflow_next_activation on nflow_workflow(next_activation, modified);

create index if not exists nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

create table if not exists nflow_workflow_action (
id int not null auto_increment primary key,
workflow_id int not null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ create table if not exists nflow_workflow (
drop index nflow_workflow_activation;
create index nflow_workflow_activation on nflow_workflow(next_activation, modified);

create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

create table if not exists nflow_workflow_action (
id int not null auto_increment primary key,
workflow_id int not null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ create table if not exists nflow_workflow (
drop index nflow_workflow_activation;
create index nflow_workflow_activation on nflow_workflow(next_activation, modified);

create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

drop trigger if exists nflow_workflow_insert;

create trigger nflow_workflow_insert before insert on `nflow_workflow`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ create table nflow_workflow (
create index nflow_workflow_activation on nflow_workflow (next_activation)
/

create index nflow_workflow_polling on nflow_workflow (next_activation, status, executor_id, executor_group)
/

create sequence nflow_workflow_id_seq
/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ create trigger update_nflow_modified before update on nflow_workflow for each ro
drop index if exists nflow_workflow_activation;
create index nflow_workflow_activation on nflow_workflow(next_activation, modified);

drop index if exists nflow_workflow_polling;
create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

create type action_type as enum ('stateExecution', 'stateExecutionFailed', 'recovery', 'externalChange');
create table if not exists nflow_workflow_action (
id serial primary key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ end;
drop index nflow_workflow_activation;
create index nflow_workflow_activation on nflow_workflow(next_activation, modified);

create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

create table nflow_workflow_action (
id int not null identity(1,1) primary key,
workflow_id int not null,
Expand All @@ -46,12 +48,18 @@ create table nflow_workflow_action (
constraint nflow_workflow_action_uniq unique (workflow_id, id)
);

create index nflow_workflow_action_workflow on nflow_workflow_action(workflow_id);

alter table nflow_workflow add constraint fk_workflow_parent
foreign key (parent_workflow_id, parent_action_id) references nflow_workflow_action (workflow_id, id) on update no action;

create index nflow_workflow_parent on nflow_workflow(parent_workflow_id, parent_action_id);

alter table nflow_workflow add constraint fk_workflow_root
foreign key (root_workflow_id) references nflow_workflow (id) on update no action;

create index nflow_workflow_root on nflow_workflow(root_workflow_id);

create table nflow_workflow_state (
workflow_id int not null,
action_id int not null,
Expand All @@ -61,6 +69,8 @@ create table nflow_workflow_state (
foreign key (workflow_id) references nflow_workflow(id) on delete cascade
);

create index nflow_workflow_state_workflow on nflow_workflow_state(workflow_id);

create table nflow_executor (
id int not null identity(1,1) primary key,
host varchar(253) not null,
Expand Down Expand Up @@ -120,6 +130,14 @@ create table nflow_archive_workflow (
constraint nflow_archive_workflow_uniq unique (type, external_id, executor_group)
);

create index nflow_archive_workflow_activation on nflow_archive_workflow(next_activation, modified);

create index nflow_archive_workflow_polling on nflow_archive_workflow(next_activation, status, executor_id, executor_group);

create index nflow_archive_workflow_parent on nflow_archive_workflow(parent_workflow_id, parent_action_id);

create index nflow_archive_workflow_root on nflow_archive_workflow(root_workflow_id);

create table nflow_archive_workflow_action (
id int not null primary key,
workflow_id int not null,
Expand All @@ -134,6 +152,8 @@ create table nflow_archive_workflow_action (
constraint nflow_archive_workflow_action_uniq unique (workflow_id, id)
);

create index nflow_archive_workflow_action_workflow on nflow_archive_workflow_action(workflow_id);

create table nflow_archive_workflow_state (
workflow_id int not null,
action_id int not null,
Expand All @@ -142,3 +162,5 @@ create table nflow_archive_workflow_state (
primary key (workflow_id, action_id, state_key),
foreign key (workflow_id) references nflow_archive_workflow(id) on delete cascade
);

create index nflow_archive_workflow_state_workflow on nflow_archive_workflow_state(workflow_id);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create index if not exists nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
create index nflow_workflow_polling on nflow_workflow (next_activation, status, executor_id, executor_group)
/
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
drop index if exists nflow_workflow_polling;
create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
create index nflow_workflow_polling on nflow_workflow(next_activation, status, executor_id, executor_group);

create index nflow_workflow_parent on nflow_workflow(parent_workflow_id, parent_action_id);

create index nflow_workflow_root on nflow_workflow(root_workflow_id);

create index nflow_workflow_action_workflow on nflow_workflow_action(workflow_id);

create index nflow_workflow_state_workflow on nflow_workflow_state(workflow_id);

create index nflow_archive_workflow_activation on nflow_archive_workflow(next_activation, modified);

create index nflow_archive_workflow_polling on nflow_archive_workflow(next_activation, status, executor_id, executor_group);

create index nflow_archive_workflow_parent on nflow_archive_workflow(parent_workflow_id, parent_action_id);

create index nflow_archive_workflow_root on nflow_archive_workflow(root_workflow_id);

create index nflow_archive_workflow_action_workflow on nflow_archive_workflow_action(workflow_id);

create index nflow_archive_workflow_state_workflow on nflow_archive_workflow_state(workflow_id);