Skip to content

fix: [#807] queue.Shutdown doesn't stop the queue as expected#1252

Merged
hwbrzzl merged 2 commits intov1.16.xfrom
bowen/#807
Oct 30, 2025
Merged

fix: [#807] queue.Shutdown doesn't stop the queue as expected#1252
hwbrzzl merged 2 commits intov1.16.xfrom
bowen/#807

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Oct 29, 2025

📑 Description

Closes goravel/goravel#807

This pull request improves the reliability and logging accuracy of the worker queue system, particularly around shutdown behavior and log timestamp precision. It also enhances test coverage for worker shutdown scenarios and introduces a helper for timezone retrieval.

Worker shutdown reliability and test coverage:

  • Improved the Shutdown method in queue/worker.go to ensure proper closure of the failed job channel and waiting for all worker goroutines to finish before shutting down, preventing premature termination and potential race conditions.
  • Added comprehensive tests in queue/worker_test.go to verify that shutdown waits for workers and job processing to complete, including scenarios with multiple jobs and failed job logging.
  • Added the mock package import to support new test cases using mock expectations.

Logging improvements:

  • Updated log timestamp formatting in both log/formatter/general.go and worker log methods in queue/worker.go to include milliseconds and respect the default timezone, improving log precision for debugging and monitoring. [1] [2] [3] [4]

Timezone utilities:

  • Added a DefaultTimezone helper function in support/carbon/carbon.go to retrieve the default timezone, supporting timezone-aware operations.

✅ Checks

  • Added test cases for my code

@hwbrzzl hwbrzzl requested a review from a team as a code owner October 29, 2025 11:43
Copilot AI review requested due to automatic review settings October 29, 2025 11:43
}

timestamp := carbon.FromStdTime(entry.Time).ToDateTimeMilliString()
timestamp := carbon.FromStdTime(entry.Time, carbon.DefaultTimezone()).ToDateTimeMilliString()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was local previously, should use the DefaultTimezone.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 794c7e3 Previous: 34d675d Ratio
Benchmark_DecryptString 6122 ns/op 2032 B/op 16 allocs/op 2098 ns/op 2032 B/op 16 allocs/op 2.92
Benchmark_DecryptString - ns/op 6122 ns/op 2098 ns/op 2.92

This comment was automatically generated by workflow using github-action-benchmark.

@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v1.16.x@3b9edf6). Learn more about missing BASE report.

Files with missing lines Patch % Lines
support/carbon/carbon.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v1.16.x    #1252   +/-   ##
==========================================
  Coverage           ?   67.99%           
==========================================
  Files              ?      216           
  Lines              ?    11608           
  Branches           ?        0           
==========================================
  Hits               ?     7893           
  Misses             ?     3335           
  Partials           ?      380           

☔ 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the worker shutdown process and improves timestamp formatting across the codebase. It ensures that worker goroutines properly wait for completion before shutting down, and adds a new DefaultTimezone() function to the carbon wrapper.

  • Adds proper synchronization to worker shutdown by waiting for all goroutines to complete
  • Improves timestamp precision by switching from ToDateTimeString() to ToDateTimeMilliString()
  • Adds explicit timezone handling for log timestamp formatting

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
support/carbon/carbon.go Adds DefaultTimezone() wrapper function to expose the carbon library's default timezone
queue/worker.go Enhances Shutdown() to wait for goroutines, updates timestamp formatting to millisecond precision
queue/worker_test.go Adds comprehensive shutdown tests covering various scenarios (multiple workers, failed jobs, blocking behavior)
log/formatter/general.go Updates timestamp formatting to use explicit default timezone parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

devhaozi
devhaozi previously approved these changes Oct 29, 2025
Copy link
Member

@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hwbrzzl hwbrzzl merged commit 4def96d into v1.16.x Oct 30, 2025
19 of 21 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#807 branch October 30, 2025 07:46
hwbrzzl added a commit that referenced this pull request Oct 31, 2025
* correctly set cc and bcc headers (#1144)

* correct the error return from SendMailJob handle (#1147)

* fix: [#743] package make command generates correct code (#1151) (#1152)

(cherry picked from commit 93dc8a3)

* fix: [#749] The path is incorrect when publishing package files (#1157)

* chore: optimize assertions for package installation (#1160)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting

* optimize

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166)

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method

* fix tests

* upgrade: v1.16.1

* fix: [#762] handle panic when using transaction (#1183)

* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint

* fix: [#768] facades.DB will panic when migrating a new column (#1185)

* fix: [#768] facades.DB will panic when migrating a new column

* optimize

* optimize

* feat: [#770] Add a SelectRaw function for the ORM (#1186)

* fix: [#770] Add a SelectRaw function for the ORM

* fix: [#770] Add a SelectRaw function for the ORM

* fix ci

* upgrade: v1.16.3

* fix: comand cannot be run concurrently (#1243)

* fix: comand cannot be run concurrently

* fix ci

* fix ci

* optimize

* optimize

* optimize

* optimize

* optimize global options

* fix ci

* upgrade v1.16.4

* fix: [#807] queue.Shutdown doesn't stop the queue as expected (#1252)

* fix: [#807] queue.Shutdown doesn't stop the queue as expected

* optimize

* upgrade: v1.16.5

* fix

* Update queue/worker_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* optimize

---------

Co-authored-by: krishan kumar <84431594+kkumar-gcc@users.noreply.github.com>
Co-authored-by: ALMAS <almas.cc@icloud.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
hwbrzzl added a commit that referenced this pull request Oct 31, 2025
* correctly set cc and bcc headers (#1144)

* correct the error return from SendMailJob handle (#1147)

* fix: [#743] package make command generates correct code (#1151) (#1152)

(cherry picked from commit 93dc8a3)

* fix: [#749] The path is incorrect when publishing package files (#1157)

* chore: optimize assertions for package installation (#1160)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting (#1162)

* fix: The configuredServiceProviders, publishes and publishGroups are not reset when Booting

* optimize

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method (#1166)

* fix: [#738] The Orm Creating event can be triggered when the query with the Model method

* fix tests

* upgrade: v1.16.1

* fix: [#762] handle panic when using transaction (#1183)

* fix: [#762] handle panic when using transaction

* v1.16.2

* optimize

* fix lint

* fix: [#768] facades.DB will panic when migrating a new column (#1185)

* fix: [#768] facades.DB will panic when migrating a new column

* optimize

* optimize

* feat: [#770] Add a SelectRaw function for the ORM (#1186)

* fix: [#770] Add a SelectRaw function for the ORM

* fix: [#770] Add a SelectRaw function for the ORM

* fix ci

* upgrade: v1.16.3

* fix: comand cannot be run concurrently (#1243)

* fix: comand cannot be run concurrently

* fix ci

* fix ci

* optimize

* optimize

* optimize

* optimize

* optimize global options

* fix ci

* upgrade v1.16.4

* fix: [#807] queue.Shutdown doesn't stop the queue as expected (#1252)

* fix: [#807] queue.Shutdown doesn't stop the queue as expected

* optimize

* upgrade: v1.16.5

* fix

* Update queue/worker_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* optimize

---------

Co-authored-by: krishan kumar <84431594+kkumar-gcc@users.noreply.github.com>
Co-authored-by: ALMAS <almas.cc@icloud.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

3 participants