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

Pending job number seems incorrect #1311

Closed
jasonmccreary opened this issue Sep 5, 2023 · 8 comments · Fixed by #1315
Closed

Pending job number seems incorrect #1311

jasonmccreary opened this issue Sep 5, 2023 · 8 comments · Fixed by #1315
Labels

Comments

@jasonmccreary
Copy link
Contributor

Horizon Version

5.19.1

Laravel Version

10.19.0

PHP Version

8.2.9

Redis Driver

Predis

Redis Version

1.1.10

Database Driver & Version

No response

Description

It appears the "Pending Jobs" number may be incorrect or misleading when there are failed jobs. This batch is complete and 160 did fail. However, no more are pending.

Screenshot 2023-09-05 at 7 47 17 PM

I would expect this number to be 0 since the batch is complete. Or, if it is to indicate the number of "Incomplete Jobs", then maybe that should have a separate title. Depending on the direction, the "Completed Jobs" and its subtitle might need to be adjusted as currently I would expect it to be 484.

I see the same thing for all my recent batched jobs with failures - the "Pending Jobs" and "Failed Jobs" numbers are the same.

Steps To Reproduce

Run a batched job with some failures. You should see "Pending Jobs" and "Failed Jobs" are the same number.

@driesvints
Copy link
Member

Hey @jasonmccreary. I believe these numbers are correct. This view is just a direct representation of the values of a batch in Laravel: https://github.com/laravel/framework/blob/2e3d23fc89c5c9e9841962d5c9bf0e3881a81929/src/Illuminate/Bus/Batch.php#L445-L457

There's pending jobs which are basically the failed jobs which still need to run, there's completed jobs and then there's a total number of jobs (completed + pending/failed).

@jasonmccreary
Copy link
Contributor Author

Thanks for the explanation. I still wonder if the wording could be adjusted as "pending" to me means needs to be run. I see how "failed" falls into that category though. No biggie.

@driesvints
Copy link
Member

I think it's best we just use the wording as is on the batch array personally. You can always try a PR to see if Taylor would accept it 👍

@crynobone crynobone reopened this Sep 12, 2023
@crynobone
Copy link
Member

crynobone commented Sep 12, 2023

Screenshot 2023-09-05 at 7 47 17 PM

Total Job value is in fact incorrect, at the moment it calculated from (totals - pendingJobs), when it should show Completed Jobs (including failed) 484 (100%)

<div class="row mb-2">
<div class="col-md-2 text-muted">Total Jobs</div>
<div class="col">{{batch.totalJobs}}</div>
</div>
<div class="row mb-2">
<div class="col-md-2 text-muted">Pending Jobs</div>
<div class="col">{{batch.pendingJobs}}</div>
</div>
<div class="row mb-2">
<div class="col-md-2 text-muted">Failed Jobs</div>
<div class="col">{{batch.failedJobs}}</div>
</div>
<div class="row">
<div class="col-md-2 text-muted">Completed Jobs<br><small>(Including Failed)</small></div>
<div class="col">{{ (batch.totalJobs-batch.pendingJobs) }} ({{batch.progress}}%)</div>
</div>

@crynobone
Copy link
Member

Alternatively we should follow Illuminate\Bus\Batch conversion of "Processed Jobs" (totals - pendingJobs) and displayed it as Processed Jobs 324 (67%)

@driesvints
Copy link
Member

Right, good spot @crynobone. Sorry about that @jasonmccreary

taylorotwell pushed a commit that referenced this issue Sep 12, 2023
…#1315)

* Use available `batch.processedJobs` value from `Illuminate\Bus\Batch`

fixes #1311

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Compile Assets

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: crynobone <[email protected]>
@jasonmccreary
Copy link
Contributor Author

@driesvints, no worries. Glad it got reopened.

@topclaudy
Copy link

Similar issue:

Screenshot 2024-08-16 at 18 19 17

Processed/Completed jobs 100%, no failures but 6 pending (stuck).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants