Skip to content

Schedule workflow randomly skipping execution cycles #6820

@xtyinbiao

Description

@xtyinbiao

Expected Behavior

this is create schedule function:

public String createSchedule(TemporalScheduleBO temporalScheduleBO) {
try {
ScheduleClient client = ScheduleClient.newInstance(
service(), ScheduleClientOptions.newBuilder().setNamespace(temporalScheduleBO.getNamespace()).build());

        Schedule schedule =
                Schedule.newBuilder()
                        .setAction(ScheduleActionStartWorkflow.newBuilder()
                                .setArguments(temporalScheduleBO.getParams())
                                .setWorkflowType(temporalScheduleBO.getWorkflowTypeName())
                                .setOptions(WorkflowOptions.newBuilder()
                                        .setTaskQueue(temporalScheduleBO.getTaskQueueName())
                                        .setWorkflowId(temporalScheduleBO.getWorkflowId())
                                        .build())
                                .build())
                        .setSpec(ScheduleSpec.newBuilder()
                                .setCronExpressions(temporalScheduleBO.getCronString())

// .setIntervals(temporalScheduleBO.getInterval())
// .setCalendars(temporalScheduleBO.getCalendar())
.build())
.setPolicy(SchedulePolicy.newBuilder()
.setOverlap(ScheduleOverlapPolicy.SCHEDULE_OVERLAP_POLICY_ALLOW_ALL)
.setCatchupWindow(Duration.ofSeconds(30))
.build())
.setState(ScheduleState.newBuilder()
.setLimitedAction(false)
.setRemainingActions(30)
.build())
.build();

        ScheduleHandle handle =
                client.createSchedule(temporalScheduleBO.getName(), schedule, ScheduleOptions.newBuilder().build());
        return handle.getId();

    } catch (ScheduleAlreadyRunningException e) {
        log.info("schedule already exists, is running, skip create: {}", temporalScheduleBO.getWorkflowId());
        return temporalScheduleBO.getName();
    } catch (ScheduleException e) {
        if(e.getCause().getMessage().contains("ALREADY_EXISTS")) {
            log.info("schedule already exists, skip create: {}", temporalScheduleBO.getWorkflowId());
            return temporalScheduleBO.getName();
        } else {
            throw e;
        }
    }
}

Expect to run every 5 minutes

Actual Behavior

Randomly miss a run

Steps to Reproduce the Problem

Specifications

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions