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

CAM-14006: avoid job log query on incident creation #1665

Closed
wants to merge 2 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.camunda.bpm.engine.EntityTypes;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.externaltask.ExternalTask;
import org.camunda.bpm.engine.history.HistoricExternalTaskLog;
import org.camunda.bpm.engine.impl.ProcessEngineLogger;
import org.camunda.bpm.engine.impl.bpmn.helper.BpmnExceptionHandler;
import org.camunda.bpm.engine.impl.bpmn.helper.BpmnProperties;
Expand Down Expand Up @@ -622,23 +621,6 @@ public Map<String, Class> getReferencedEntitiesIdAndClass() {
}

public String getLastFailureLogId() {
if (lastFailureLogId == null) {
// try to find the last failure log in the database,
// can occur if setRetries is called manually since
// otherwise the failure handling ensures that a log
// entry is written before the incident is created
List<HistoricExternalTaskLog> logEntries = Context.getCommandContext()
.getProcessEngineConfiguration()
.getHistoryService()
.createHistoricExternalTaskLogQuery()
.failureLog()
.externalTaskId(id)
.orderByTimestamp().desc()
.list();
if (!logEntries.isEmpty()) {
lastFailureLogId = logEntries.get(0).getId();
}
}
return lastFailureLogId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Map;
import java.util.Set;

import org.camunda.bpm.engine.history.HistoricJobLog;
import org.camunda.bpm.engine.impl.ProcessEngineLogger;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.context.Context;
Expand Down Expand Up @@ -659,23 +658,6 @@ public void postLoad() {
}

public String getLastFailureLogId() {
if (lastFailureLogId == null) {
// try to find the last failure log in the database,
// can occur if setRetries is called manually since
// otherwise the failure handling ensures that a log
// entry is written before the incident is created
List<HistoricJobLog> logEntries = Context.getCommandContext()
tmetzke marked this conversation as resolved.
Show resolved Hide resolved
.getProcessEngineConfiguration()
.getHistoryService()
.createHistoricJobLogQuery()
.failureLog()
.jobId(id)
.orderPartiallyByOccurrence().desc()
.list();
if (!logEntries.isEmpty()) {
lastFailureLogId = logEntries.get(0).getId();
}
}
return lastFailureLogId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ bigint,
TENANT_ID_ varchar(64),
CREATE_TIME_ timestamp,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ varchar(64),
TENANT_ID_ varchar(64),
PRIORITY_ bigint NOT NULL DEFAULT 0,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ bigint,
TENANT_ID_ varchar(64),
CREATE_TIME_ timestamp,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down Expand Up @@ -337,6 +338,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ varchar(64),
TENANT_ID_ varchar(64),
PRIORITY_ bigint not null default 0,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ integer,
TENANT_ID_ varchar(64),
CREATE_TIME_ timestamp,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ varchar(64),
TENANT_ID_ varchar(64),
PRIORITY_ bigint NOT NULL DEFAULT 0,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ bigint,
TENANT_ID_ varchar(64),
CREATE_TIME_ datetime(3),
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ varchar(64),
TENANT_ID_ varchar(64),
PRIORITY_ bigint NOT NULL DEFAULT 0,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ numeric(19,0),
TENANT_ID_ nvarchar(64),
CREATE_TIME_ datetime2,
LAST_FAILURE_LOG_ID_ nvarchar(64),
primary key (ID_)
);

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ nvarchar(64),
TENANT_ID_ nvarchar(64),
PRIORITY_ numeric(19,0) NOT NULL DEFAULT 0,
LAST_FAILURE_LOG_ID_ nvarchar(64),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ bigint,
TENANT_ID_ varchar(64),
CREATE_TIME_ datetime,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ varchar(64),
TENANT_ID_ varchar(64),
PRIORITY_ bigint NOT NULL DEFAULT 0,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ NUMBER(19,0),
TENANT_ID_ NVARCHAR2(64),
CREATE_TIME_ TIMESTAMP(6),
LAST_FAILURE_LOG_ID_ NVARCHAR2(64),
primary key (ID_)
);

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ NVARCHAR2(64),
TENANT_ID_ NVARCHAR2(64),
PRIORITY_ NUMBER(19,0) DEFAULT 0 NOT NULL,
LAST_FAILURE_LOG_ID_ NVARCHAR2(64),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ create table ACT_RU_EXECUTION (

create table ACT_RU_JOB (
ID_ varchar(64) NOT NULL,
REV_ integer,
REV_ integer,
TYPE_ varchar(255) NOT NULL,
LOCK_EXP_TIME_ timestamp,
LOCK_OWNER_ varchar(255),
Expand All @@ -131,6 +131,7 @@ create table ACT_RU_JOB (
SEQUENCE_COUNTER_ bigint,
TENANT_ID_ varchar(64),
CREATE_TIME_ timestamp,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down Expand Up @@ -334,6 +335,7 @@ create table ACT_RU_EXT_TASK (
ACT_INST_ID_ varchar(64),
TENANT_ID_ varchar(64),
PRIORITY_ bigint NOT NULL DEFAULT 0,
LAST_FAILURE_LOG_ID_ varchar(64),
primary key (ID_)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);
tmetzke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD LAST_FAILURE_LOG_ID_ nvarchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD LAST_FAILURE_LOG_ID_ nvarchar(64);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD LAST_FAILURE_LOG_ID_ NVARCHAR2(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD LAST_FAILURE_LOG_ID_ NVARCHAR2(64);
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@
--

insert into ACT_GE_SCHEMA_LOG
values ('600', CURRENT_TIMESTAMP, '7.17.0');
values ('600', CURRENT_TIMESTAMP, '7.17.0');

-- https://jira.camunda.com/browse/CAM-14006 --
ALTER TABLE ACT_RU_JOB
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);

ALTER TABLE ACT_RU_EXT_TASK
ADD COLUMN LAST_FAILURE_LOG_ID_ varchar(64);
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="priority" column="PRIORITY_" jdbcType="BIGINT" />
<result property="businessKey" column="BUSINESS_KEY_" jdbcType="VARCHAR" />
<result property="lastFailureLogId" column="LAST_FAILURE_LOG_ID_" jdbcType="VARCHAR" />
<!-- note: if you add mappings here, make sure to select the columns in 'columnSelection' -->
</resultMap>

Expand All @@ -68,6 +69,7 @@
ACT_INST_ID_,
TENANT_ID_,
PRIORITY_,
LAST_FAILURE_LOG_ID_,
REV_
) values (
#{id, jdbcType=VARCHAR},
Expand All @@ -86,6 +88,7 @@
#{activityInstanceId, jdbcType=VARCHAR},
#{tenantId, jdbcType=VARCHAR},
#{priority, jdbcType=BIGINT},
#{lastFailureLogId, jdbcType=VARCHAR},
1
)
</insert>
Expand All @@ -107,7 +110,8 @@
ACT_ID_ = #{activityId, jdbcType=VARCHAR},
ACT_INST_ID_ = #{activityInstanceId, jdbcType=VARCHAR},
SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
PRIORITY_ = #{priority, jdbcType=BIGINT}
PRIORITY_ = #{priority, jdbcType=BIGINT},
LAST_FAILURE_LOG_ID_ = #{lastFailureLogId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
Expand Down Expand Up @@ -451,7 +455,8 @@
RES.TENANT_ID_,
RES.PRIORITY_,
RES.BUSINESS_KEY_,
RES.VERSION_TAG_
RES.VERSION_TAG_,
RES.LAST_FAILURE_LOG_ID_
</sql>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP" />
<result property="sequenceCounter" column="SEQUENCE_COUNTER_" jdbcType="BIGINT" />
<result property="lastFailureLogId" column="LAST_FAILURE_LOG_ID_" jdbcType="VARCHAR" />
<discriminator javaType="string" column="TYPE_">
<case value="message" resultMap="messageResultMap"/>
<case value="timer" resultMap="timerResultMap"/>
Expand Down Expand Up @@ -522,7 +523,8 @@
DEPLOYMENT_ID_ = #{deploymentId, jdbcType=VARCHAR},
HANDLER_CFG_ = #{jobHandlerConfigurationRaw, jdbcType=VARCHAR},
PRIORITY_ = #{priority, jdbcType=BIGINT},
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT}
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT},
LAST_FAILURE_LOG_ID_ = #{lastFailureLogId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
Expand Down Expand Up @@ -625,7 +627,8 @@
DEPLOYMENT_ID_ = #{deploymentId, jdbcType=VARCHAR},
HANDLER_CFG_ = #{jobHandlerConfigurationRaw, jdbcType=VARCHAR},
PRIORITY_ = #{priority, jdbcType=BIGINT},
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT}
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT},
LAST_FAILURE_LOG_ID_ = #{lastFailureLogId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
Expand Down Expand Up @@ -705,7 +708,8 @@
DEPLOYMENT_ID_ = #{deploymentId, jdbcType=VARCHAR},
HANDLER_CFG_ = #{jobHandlerConfigurationRaw, jdbcType=VARCHAR},
PRIORITY_ = #{priority, jdbcType=BIGINT},
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT}
SEQUENCE_COUNTER_ = #{sequenceCounter, jdbcType=BIGINT},
LAST_FAILURE_LOG_ID_ = #{lastFailureLogId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
Expand Down
Loading