Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(os/gcron): unit testing case of package gcron occasionally failed#4419

Merged
hailaz merged 7 commits intogogf:masterfrom
wanghaolong613:fix/3999
Oct 15, 2025
Merged

fix(os/gcron): unit testing case of package gcron occasionally failed#4419
hailaz merged 7 commits intogogf:masterfrom
wanghaolong613:fix/3999

Conversation

@wanghaolong613
Copy link
Contributor

@wanghaolong613 wanghaolong613 commented Sep 5, 2025

fix #3999

  1. fix jobWaiter sync.WaitGroup data race
  2. fix logger glog.ILogger data race

@hailaz hailaz requested a review from Copilot October 15, 2025 06:49
@hailaz hailaz changed the title fix:(os/gcron): unit testing case of package gcron occasionally failed fix(os/gcron): unit testing case of package gcron occasionally failed Oct 15, 2025
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 fixes unit test failures in the gcron package that were occurring due to data race conditions. The main purpose is to address concurrency issues that were causing occasional test failures.

Key changes include:

  • Added thread-safe access to the logger field with RWMutex protection
  • Implemented proper synchronization for the jobWaiter to prevent race conditions
  • Added a new non-blocking graceful shutdown method (StopGracefullyNonBlocking)

Reviewed Changes

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

Show a summary per file
File Description
os/gcron/gcron_cron.go Added mutex protection for logger field and running state; implemented non-blocking graceful shutdown
os/gcron/gcron_entry.go Added proper synchronization checks before adding to jobWaiter
os/gcron/gcron.go Added wrapper function for new non-blocking graceful shutdown method
os/gcron/gcron_z_unit_test.go Modified tests to use goroutines and added proper cleanup with defer statements
os/gcron/gcron_z_unit_entry_test.go Wrapped cron job additions in goroutines for thread safety testing
os/gcron/gcron_z_example_1_test.go Added new example and updated job names to avoid conflicts

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hailaz hailaz merged commit 2742c98 into gogf:master Oct 15, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

os/gcron: unit testing case of package gcron occasionally failed

2 participants