Skip to content

Conversation

zsistla
Copy link
Contributor

@zsistla zsistla commented Sep 20, 2025

Multiverse and soak tests revealed a bug with naming Job transactions when the job throws an exception.

The issue is that we key off of raiseBeforeJobEvent and raiseAfterJobEvent, but in the case of failure due to exception(https://github.com/illuminate/queue/blob/12.x/Worker.php#L447 ), raiseAfterJobEvent doesn't get called, so we never do the final end txn to close things off here and when the next retry calls raiseBeforeJobEvent again it ends the txn and discards anything that happened before (in this case the logs/exceptions/segment of the previous retry attempt).

Solution is to wrap the following so we can handle the exception case in the after/clean callbacks.
{Illuminate\Queue\Worker} function={process} async
https://github.com/illuminate/queue/blob/12.x/Worker.php#L425

Illuminate\Queue\SyncQueue::executeJob/push for sync
https://github.com/illuminate/queue/blob/12.x/SyncQueue.php#L123

@newrelic-php-agent-bot
Copy link

newrelic-php-agent-bot commented Sep 20, 2025

Test Suite Status Result
Multiverse 6/16 passing
SOAK 84/85 passing

@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.44%. Comparing base (1e5fa6d) to head (69509f2).

Files with missing lines Patch % Lines
agent/fw_laravel_queue.c 93.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1122      +/-   ##
==========================================
+ Coverage   78.15%   78.44%   +0.28%     
==========================================
  Files         193      193              
  Lines       28053    28053              
==========================================
+ Hits        21925    22006      +81     
+ Misses       6128     6047      -81     
Flag Coverage Δ
agent-for-php-7.2 78.41% <ø> (+<0.01%) ⬆️
agent-for-php-7.3 78.43% <ø> (+<0.01%) ⬆️
agent-for-php-7.4 78.29% <ø> (+<0.01%) ⬆️
agent-for-php-8.0 77.78% <93.75%> (+0.30%) ⬆️
agent-for-php-8.1 78.10% <93.75%> (+0.30%) ⬆️
agent-for-php-8.2 77.71% <93.75%> (+0.30%) ⬆️
agent-for-php-8.3 77.71% <93.75%> (+0.30%) ⬆️
agent-for-php-8.4 77.73% <93.75%> (+0.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bduranleau-nr bduranleau-nr added this to the next-release milestone Sep 23, 2025
@bduranleau-nr bduranleau-nr changed the base branch from main to dev September 25, 2025 16:52
@hahuja2 hahuja2 self-requested a review October 3, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants