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

Handle concurrent access to a pipeline's status field #1794

Merged
merged 7 commits into from
Aug 21, 2024

Conversation

hariso
Copy link
Contributor

@hariso hariso commented Aug 19, 2024

Description

Closes #1778.

The approach that we initially planned didn't quite work and was changed to use a sync.Mutex because of following:

  1. Having an exported field (and this is part of the "public" Conduit API) that's an atomic is sub-optimal user experience because it forces the user to work with the low-level constructs. In other words we should either expose a field or methods that work with just the pipeline.Status field.
  2. With a field, it's possible to simply overwrite it: myPipeline.Status = atomic.Pointer{}
  3. We still need to provide a getter and setter because otherwise working with atomic.Pointer would involve a few steps:
    // set status
    myPipeline.Status.Store(lang.Ptr(theStatus))
    // get status
    theStatus := *myPipeline.Status.Load()
  4. A pointer, we need to make sure the field is properly initialized.

For the reasons above, this PR uses a sync.Mutex and adds a getter and setter method for the status field, that is now unexported.

Quick checks

  • I have followed the Code Guidelines.
  • There is no other pull request for the same update/change.
  • I have written unit tests.
  • I have made sure that the PR is of reasonable size and can be easily reviewed.

@hariso hariso marked this pull request as ready for review August 19, 2024 12:35
@hariso hariso requested a review from a team as a code owner August 19, 2024 12:35
Copy link
Member

@raulb raulb left a comment

Choose a reason for hiding this comment

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

@hariso LGTM! I only posted a non blocking question.

pkg/pipeline/instance.go Show resolved Hide resolved
pkg/pipeline/instance.go Show resolved Hide resolved
@hariso hariso enabled auto-merge (squash) August 21, 2024 16:09
@hariso hariso merged commit 38ca22d into main Aug 21, 2024
3 checks passed
@hariso hariso deleted the haris/pipeline-recovery/atomic-status branch August 21, 2024 16:14
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.

[Recovery] Make pipeline status an atomic value
2 participants