Skip to content

Conversation

gaius-qi
Copy link
Member

Description

This pull request refactors the logic for fetching and constructing group job states in the Job service, with a focus on improving concurrency safety and error handling. The main changes introduce mutex protection for shared state, replace the previous group job state constructor, and add a new logging helper. These updates help prevent data races and improve the clarity of error reporting.

Concurrency and data safety improvements:

  • Refactored the concurrent collection of jobStates in GetGroupJobState to use a mutex (sync.Mutex) and append, replacing the previous approach that used indexed assignment. This prevents potential data races when multiple goroutines update the shared slice.
  • Replaced the newGroupJobState constructor with constructGroupJobState, ensuring a single, consistent method for building GroupJobState instances. [1] [2]

Error handling and logging enhancements:

  • Added error logging with the new WithGroupUUID logger helper when group job state retrieval fails, improving visibility into failures. [1] [2]
  • Introduced the WithGroupUUID helper in internal/dflog/logger.go for more granular log context.

General codebase improvements:

  • Added the sync package import to support the new mutex-based concurrency logic.

Related Issue

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

…nal job

Signed-off-by: Gaius <gaius.qi@gmail.com>
@gaius-qi gaius-qi added this to the v2.4.0 milestone Aug 13, 2025
@gaius-qi gaius-qi self-assigned this Aug 13, 2025
@gaius-qi gaius-qi added the enhancement New feature or request label Aug 13, 2025
yxxhero
yxxhero previously approved these changes Aug 13, 2025
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.62%. Comparing base (06b8563) to head (5a4345f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/job/job.go 0.00% 23 Missing ⚠️
internal/dflog/logger.go 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4270      +/-   ##
==========================================
- Coverage   32.62%   32.62%   -0.01%     
==========================================
  Files         349      349              
  Lines       41363    41368       +5     
==========================================
  Hits        13496    13496              
- Misses      26991    26996       +5     
  Partials      876      876              
Flag Coverage Δ
unittests 32.62% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
internal/dflog/logger.go 55.28% <0.00%> (-0.92%) ⬇️
internal/job/job.go 13.66% <0.00%> (-0.09%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

chlins
chlins previously approved these changes Aug 13, 2025
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@chlins chlins enabled auto-merge (squash) August 13, 2025 03:14
@gaius-qi gaius-qi dismissed stale reviews from yxxhero and chlins via 5a4345f August 14, 2025 02:43
@gaius-qi gaius-qi force-pushed the feature/internal-job branch from 24fa31d to 5a4345f Compare August 14, 2025 02:43
Copy link
Contributor

@LunaWhispers LunaWhispers left a comment

Choose a reason for hiding this comment

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

lgtm

@chlins chlins merged commit e169394 into main Aug 14, 2025
16 checks passed
@chlins chlins deleted the feature/internal-job branch August 14, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants