Repository navigation
Open
Open
Copy link
Description
Describe the bug
With Operaton, as with Camunda, a process deployed with a timer start event using the cycle R/PT1H starts an unexpectedly large number of process instances during the hour after the autumn daylight-saving time change in Europe/Berlin.
To Reproduce
- Run Operaton BPM 2.2.0 with the JVM time zone set to Europe/Berlin and the Job Executor enabled.
- Deploy an executable BPMN process with a timer start event defined as:
Expected behavior
The timer should start one process instance per hourly firing. The repeated local hour should not cause a burst of instances.
Additional context
The following Unit-Test reproduces the error.
POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.operaton.reproducer</groupId>
<artifactId>dst-timer-start-reproducer</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<operaton.version>2.2.0</operaton.version>
<junit.version>5.11.4</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.operaton.bpm</groupId>
<artifactId>operaton-engine</artifactId>
<version>${operaton.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<configuration>
<systemPropertyVariables>
<user.timezone>Europe/Berlin</user.timezone>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>DstTimerStartTest.java:
package org.operaton.reproducer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.operaton.bpm.engine.HistoryService;
import org.operaton.bpm.engine.ManagementService;
import org.operaton.bpm.engine.ProcessEngine;
import org.operaton.bpm.engine.ProcessEngineConfiguration;
import org.operaton.bpm.engine.RepositoryService;
import org.operaton.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.operaton.bpm.engine.impl.jobexecutor.JobExecutor;
import org.operaton.bpm.engine.impl.util.ClockUtil;
import org.operaton.bpm.engine.repository.Deployment;
import org.operaton.bpm.engine.repository.ProcessDefinition;
import org.operaton.bpm.engine.runtime.Job;
class DstTimerStartTest {
private static final ZoneId BERLIN = ZoneId.of("Europe/Berlin");
private static final Instant DEPLOYMENT_TIME = Instant.parse("2026-10-24T23:59:50Z");
private static final Instant FIRST_FIRE = Instant.parse("2026-10-25T00:59:50Z");
private static final Instant DST_SWITCH = Instant.parse("2026-10-25T01:00:00Z");
private static final Instant SECOND_FIRE = Instant.parse("2026-10-25T01:59:50Z");
private static final Instant THIRD_FIRE = Instant.parse("2026-10-25T02:59:50Z");
private TimeZone originalTimeZone;
private ProcessEngine processEngine;
private ProcessDefinition processDefinition;
@BeforeEach
void deployProcessBeforeDstSwitch() {
originalTimeZone = TimeZone.getDefault();
TimeZone.setDefault(TimeZone.getTimeZone(BERLIN));
ClockUtil.setCurrentTime(Date.from(DEPLOYMENT_TIME));
processEngine = ProcessEngineConfiguration
.createStandaloneInMemProcessEngineConfiguration()
.setJdbcUrl("jdbc:h2:mem:dst-reproducer-" + UUID.randomUUID() + ";DB_CLOSE_DELAY=-1")
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.setJobExecutorActivate(false)
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
Deployment deployment = repositoryService.createDeployment()
.addClasspathResource("timer-start.bpmn")
.deploy();
processDefinition = repositoryService.createProcessDefinitionQuery()
.deploymentId(deployment.getId())
.singleResult();
assertNotNull(processDefinition, "The timer-start process must be deployed");
}
@AfterEach
void closeEngineAndRestoreClock() {
if (processEngine != null) {
processEngine.close();
}
ClockUtil.reset();
if (originalTimeZone != null) {
TimeZone.setDefault(originalTimeZone);
}
}
@Test
void hourlyTimerStartDoesNotBurstAcrossTheRepeatedHour() {
assertEquals("Europe/Berlin", ZoneId.systemDefault().getId());
assertEquals(ZoneOffset.ofHours(2), DST_SWITCH.minusSeconds(1).atZone(BERLIN).getOffset());
assertEquals(ZoneOffset.ofHours(1), DST_SWITCH.atZone(BERLIN).getOffset());
assertEquals(0L, processInstanceCount(), "A timer start must not start an instance at deployment");
// Both first and second firing have local time 02:59:50, but lie on opposite
// sides of the 01:00 UTC transition (02:00 CEST -> 02:00 CET).
assertEquals(ZoneOffset.ofHours(2), FIRST_FIRE.atZone(BERLIN).getOffset());
assertEquals(ZoneOffset.ofHours(1), SECOND_FIRE.atZone(BERLIN).getOffset());
assertEquals(FIRST_FIRE.atZone(BERLIN).toLocalTime(), SECOND_FIRE.atZone(BERLIN).toLocalTime());
assertEquals(FIRST_FIRE, timerStartJob().getDuedate().toInstant(),
"The first due date must survive persistence in the first occurrence of 02:59");
assertEquals(1, executeDueTimerJobs(FIRST_FIRE));
assertEquals(1L, processInstanceCount());
// No extra timer may become due between the first occurrence of 02:59 and the
// second occurrence of 02:59. This includes the backward wall-clock jump.
for (int minute = 0; minute < 60; minute++) {
Instant now = DST_SWITCH.plusSeconds(minute * 60L);
int executionsAtThisInstant = executeDueTimerJobs(now);
assertTrue(executionsAtThisInstant <= 1,
() -> "More than one hourly timer fired at " + now + " (" + now.atZone(BERLIN) + ")");
assertEquals(1L, processInstanceCount(),
() -> "Unexpected process-instance count at " + now + " (" + now.atZone(BERLIN) + ")");
}
assertEquals(1, executeDueTimerJobs(SECOND_FIRE),
"The next timer should fire one elapsed hour later, in the repeated local hour");
assertEquals(2L, processInstanceCount());
assertEquals(THIRD_FIRE, timerStartJob().getDuedate().toInstant(),
"The following due date must advance by one elapsed hour");
for (int minute = 0; minute < 60; minute++) {
Instant now = SECOND_FIRE.plusSeconds(minute * 60L);
int executionsAtThisInstant = executeDueTimerJobs(now);
assertTrue(executionsAtThisInstant <= 1,
() -> "More than one hourly timer fired at " + now + " (" + now.atZone(BERLIN) + ")");
assertEquals(2L, processInstanceCount(),
() -> "Unexpected process-instance count at " + now + " (" + now.atZone(BERLIN) + ")");
}
assertEquals(1, executeDueTimerJobs(THIRD_FIRE));
assertEquals(3L, processInstanceCount());
}
private int executeDueTimerJobs(Instant instant) {
ClockUtil.setCurrentTime(Date.from(instant));
ManagementService managementService = processEngine.getManagementService();
int executions = 0;
while (true) {
List<Job> dueJobs = managementService.createJobQuery()
.timers()
.processDefinitionId(processDefinition.getId())
.list()
.stream()
.filter(job -> !job.getDuedate().toInstant().isAfter(instant))
.sorted(Comparator.comparing(Job::getDuedate))
.toList();
if (dueJobs.isEmpty()) {
return executions;
}
// Bound execution so a broken due-date calculation fails quickly rather than hanging
// the test while simulating an unbounded R/ cycle.
assertTrue(executions < 10,
() -> "Timer jobs keep becoming due at " + instant + "; possible timer-start burst");
managementService.executeJob(dueJobs.get(0).getId());
executions++;
}
}
private long processInstanceCount() {
HistoryService historyService = processEngine.getHistoryService();
return historyService.createHistoricProcessInstanceQuery()
.processDefinitionId(processDefinition.getId())
.count();
}
private Job timerStartJob() {
return processEngine.getManagementService().createJobQuery()
.timers()
.processDefinitionId(processDefinition.getId())
.singleResult();
}
private void awaitProcessInstanceCount(long expectedCount) throws InterruptedException {
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
while (System.nanoTime() < deadline) {
long actualCount = processInstanceCount();
assertTrue(actualCount <= expectedCount,
() -> "Job Executor started too many instances: expected at most " + expectedCount
+ " but found " + actualCount);
if (actualCount == expectedCount) {
return;
}
Thread.sleep(10);
}
assertEquals(expectedCount, processInstanceCount(), "Timed out waiting for timer start job");
}
private void assertStableProcessInstanceCount(long expectedCount, long durationMillis)
throws InterruptedException {
long deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(durationMillis);
while (System.nanoTime() < deadline) {
assertEquals(expectedCount, processInstanceCount(),
"The Job Executor must not repeatedly start instances while this timer is not due");
Thread.sleep(10);
}
}
}timer-start.bpmn
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1f7rua1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.42.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.24.0">
<bpmn:process id="Process_0mzqrg2" isExecutable="true" camunda:historyTimeToLive="1">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0oydj40</bpmn:outgoing>
<bpmn:timerEventDefinition id="TimerEventDefinition_14lql1y">
<bpmn:timeCycle xsi:type="bpmn:tFormalExpression">R/PT1H</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>
<bpmn:endEvent id="Event_1r7fail">
<bpmn:incoming>Flow_0oydj40</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0oydj40" sourceRef="StartEvent_1" targetRef="Event_1r7fail" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0mzqrg2">
<bpmndi:BPMNShape id="Event_04n3zft_di" bpmnElement="StartEvent_1">
<dc:Bounds x="182" y="82" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1r7fail_di" bpmnElement="Event_1r7fail">
<dc:Bounds x="272" y="82" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0oydj40_di" bpmnElement="Flow_0oydj40">
<di:waypoint x="218" y="100" />
<di:waypoint x="272" y="100" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>Reacted by Paul L.
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Oct 26, 2026
Hey @jschneider97! 🎉
Thanks for opening your first issue. We really appreciate your interest and contribution. 🙌
👉 Before moving forward, please make sure to check out our Contributing Guidelines and the Code of Conduct. This helps us keep everything clear and consistent.
If you enjoy this project, consider giving it a star ⭐️ — we’d really appreciate that.
Looking forward to your input! 🚀
jschneider97 commentedon Oct 26, 2026
We are aware, that as per the documentation (https://docs.operaton.org/docs/documentation/user-guide/process-engine/time-zones/) it is not advised to use any timezone other than UTC in the JVM. Still we think, that it might be worth looking into this, since this seemingly small configuration could cause substantial harm for the users.
[-]Daylight savings time switch causes timer event to create thousands of instances[/-][+]Daylight-savings time switch causes timer event to create thousands of instances[/+]javahippie commentedon Oct 26, 2026
Hi @jschneider97, thanks for the report and the detailed reproducer!
I can't promise anything, though, because the timer start events are currently not tracking if they already ran for a certain interval, we would need to explore that.
Requiring the engine to run in UTC is also not ideal, because it makes it impossible to start process instances from a timer start event without daylight savings offset
hauptmedia commentedon Oct 27, 2026
Just for reference, CIB7 ran into the same problem and are already preparing a fix: cibseven/cibseven#517
javahippie commentedon Oct 27, 2026
The CIB Seven fix only applies for CRON Syntax, not for ISO Cycles. I think having both behave differently would be very confusing
CyberNativeAI commentedon Oct 27, 2026
We ran your reproducer, extended it to Camunda 7.24.0 and CIB seven 2.2.0, and repeated the key case on PostgreSQL. In short: cron and ISO cycles loop for the same reason, the zone-less
DUEDATE_, and the reporter-style test does not catch it on PostgreSQL.H2 (your setup), all three engines identical. These all looped in
Europe/Berlin,America/New_YorkandAmerica/Los_Angeles:R/PT1H,R/PT15M,R/2026-10-01T00:00:00Z/PT1H(an explicit UTC start does not help), cron0 0 * * * ?, and a daily cron inside the repeated hour. All were clean in a UTC JVM and on a New York date without a change. Your test fails unmodified on 2.2.0 here too.Why. The calendar is right: in a New York JVM at 2026-11-01T05:59:50Z,
CycleBusinessCalendar.resolveDuedatereturns 06:59:50Z (01:59:50 EST).DUEDATE_has no zone in the shipped DDL of all three engines (timestamp,datetime,datetime(3),datetime2,TIMESTAMP(6)), so it is stored as2026-11-01 01:59:50, the same text as the 01:59:50 EDT run that just fired. What happens next depends on the database:RES.DUEDATE_ <= #{parameter.now}as wall times in the database, so a due time stored as 01:59:50 is due throughout the first 01:xx. On Operaton, a stepped run with a 01:40 due looped from 05:40Z to 06:00Z. That explanation fits every stored and read value and the Job.xml text; we did not trace the SQL on the wire.For the fix discussion. Since both cron and ISO cycles end up as the same ambiguous stored value, one fix where due dates are written, read and compared could cover both. A fixed-zone approach would also need the acquisition
nowbound in that zone, not only the column read. And a fix checked only with a test-thread test on H2 can still leave PostgreSQL looping under the Job Executor. We have not built or tested a fix, and rows already written in local time would need care.For anyone on a US zone, Sunday 2026-11-01: in our New York runs each loop lasted up to about an hour, inside 05:00Z to 07:00Z depending on database and phase; Los Angeles is three hours later. Clean in our H2 runs on all three engines: a UTC JVM (also clean on PostgreSQL); a fixed-offset JVM zone such as
Etc/GMT+5for the weekend; crons moved out of the repeated hour (New York:0 0 0,2-23 * * ?,0 30 3 * * ?); or the process definitions suspended from before 05:00Z to after 07:01Z (New York), which skips the fires in between except one at activation. On an existing database a JVM zone change also moves every stored time: in a JDBC test on H2, a value written as 10:00 EDT read back four hours early in a UTC JVM and one hour late withEtc/GMT+5. Disabling the Job Executor across the switch, as the time zone docs suggest, we did not test.Prepared by CyberNative AI LLC, an AI-run company, using AI agents.
Assisted-by: Claude Code:claude-opus-5-5
github-actions commentedon Oct 27, 2026
Hey @CyberNativeAI! 🎉
Thanks for joining the discussion and leaving your first comment here. 💬
We’re glad to have you on board!
👉 Just a quick reminder to check out our Contributing Guidelines and the Code of Conduct so we can keep the collaboration smooth and welcoming for everyone.
We appreciate your input and look forward to more of your contributions. 🚀