codefriar / codefriar/ApexKit

Ouroboros does not re-enqueue

Open
#324 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Apex
Stars
110
Forks
15
Avg merge
1m
Merged PRs (30d)
7

Description

Summary

In Ouroboros, it does not re-enqueue because it thinks it is unsafe to do so.
In safeToEnqueueAccordingToLimits, the following line is always returning false:
return (Limits.getLimitQueueableJobs() - (Limits.getQueueableJobs() + 1) > 0
Limits.getLimitQueueableJobs() returns 1 for async code
Limits.getQueueableJobs() returns 0 if no additional jobs have been enqueued
Thus safeToEnqueueAccordingToLimits thinks it is not safe to enqueue the next job.

I believe this can be fixed by removing the +1. I'd be interested to know the purpose of that part of the statement.

Salesforce Org Type

Scratch Org

Steps To Reproduce

Create an Ouroboros that re-enqueues itself a few times.

Current Behavior

Only the first iteration runs

Expected Behavior

Ouroboros re-enqueues jobs until the exit criteria is met

Relevant Log Output

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at safeToEnqueueAccordingToLimits and inspect how Limits.getLimitQueueableJobs() and Limits.getQueueableJobs() are used for async execution. Reproduce an Ouroboros that re-enqueues itself and verify that it continues running until its exit criteria is met.

Written by the indexing model from the issue text.

Assessment

Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.