-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat: multiple mutexes and semaphores #13358
Conversation
e662199
to
1f1bb7a
Compare
6f34440
to
3070c90
Compare
@jessesuen Would you like to review this as well since you might be relying on the existing behavior of the synchronization feature? |
It shouldn't be a breaking change for existing users. |
09a3526
to
f17a0b6
Compare
@Joibel could you please re-format your PR descriptions? I think they're line-breaking at 80 chars or something, which depending on the width of the GH description, can sometimes cause a double line-break or otherwise look weird. It also makes quoting look strange too, as other comments are not at that line width. I manually re-formatted a few of your other PRs, but this one is quite long I can review this as I had worked briefly on these, but I'm not promising any timeline as I already have too many things on my plate (including all the metrics PRs, and docs/UI/Server and some others are often falling on my plate too 😕 most features have docs portions too...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly backwards compatible. It is minorly breaking only in as much as semaphore + mutex at the same time will now actually take both, whereas before it ignored the mutex.
Are we considering this breaking? The silent ignore is a pure bug to me, where the user intent was to do both, but you'd find out after that didn't happen.
I was actually thinking that would be its own fix PR that would be backported to older versions, whereas the feature to have multiple ofc would not be backported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version specifiers are needed everywhere. Also the parallelism doc should be split into its own PR as it is very backport worthy.
f17a0b6
to
e26f133
Compare
These are intertwined features in my implementation. One semaphore and one mutex is just a special case of multiple synchronization items. The bulk of this PR is necessary to make that case work, and I'd consider it too invasive to backport. I consider the Alternatively wording sufficient to say it was not supposed to work before, hence should not be backported. argo-workflows/docs/synchronization.md Line 11 in c16c5e4
I'm not fussed whether we call this breaking though. |
Split from #13358 This is a rewrite of the docs for synchronization and parallelism, split from the multiple mutexes and semaphores code. This PR is suitable for backporting to 3.5 and 3.4. * New markdown document on parallelism: - locks and parallelism will generally have different use cases. I think it is better not to have them on the same page so you don't think you could use one instead of the other - As far as I know more pages doesn't cost us anything. - priority for parallelism documented - paralellism in workflow and template spec better explained * Synchronisation adds: - information on queuing - better explain whay a mutex is - explain behaviour in case of specifying both semaphore and mutex Conform to style guide and 1 sentence per line Signed-off-by: Alan Clucas <[email protected]>
Split from #13358 This is a rewrite of the docs for synchronization and parallelism, split from the multiple mutexes and semaphores code. This PR is suitable for backporting to 3.5 and 3.4. * New markdown document on parallelism: - locks and parallelism will generally have different use cases. I think it is better not to have them on the same page so you don't think you could use one instead of the other - As far as I know more pages doesn't cost us anything. - priority for parallelism documented - paralellism in workflow and template spec better explained * Synchronisation adds: - information on queuing - better explain whay a mutex is - explain behaviour in case of specifying both semaphore and mutex Conform to style guide and 1 sentence per line Signed-off-by: Alan Clucas <[email protected]>
e26f133
to
2b06b8a
Compare
Gotcha. Yea when I examined the issue it could not be done easily either (whereas multi-semaphore was more straightforward). In that case, I am wondering whether we should have a separate "fix" to backport that errors out when both are provided. Since this feature will only land in 3.6 and the silent ignore in earlier versions is very confusing/surprising as it stands |
Yes, this would be nice if it got done. |
Split from #13358 This is a rewrite of the docs for synchronization and parallelism, split from the multiple mutexes and semaphores code. This PR is suitable for backporting to 3.5 and 3.4. * New markdown document on parallelism: - locks and parallelism will generally have different use cases. I think it is better not to have them on the same page so you don't think you could use one instead of the other - As far as I know more pages doesn't cost us anything. - priority for parallelism documented - paralellism in workflow and template spec better explained * Synchronisation adds: - information on queuing - better explain whay a mutex is - explain behaviour in case of specifying both semaphore and mutex Conform to style guide and 1 sentence per line Signed-off-by: Alan Clucas <[email protected]>
7618198
to
cda4b03
Compare
dc81fbf
to
97f7b03
Compare
86e3800
to
cf67c5e
Compare
Fixes #5022 Fixes #11859 This is mostly backwards compatbile. It is minorly breaking only in as much as semaphore + mutex at the same time will now require both, whereas before it ignored the mutex. As a workflows users I would like to be able to use more than one sync option in a workflow or template. Added `mutexes` and `semaphores` to the `synchronization` block in workflow types as lists. Legacy `mutex` and `semaphore` kept in and continue to work (will be added to the mutexes/semaphores list) but marked for deprecation. Logic changed to acquire a full list of all synchronization items (`syncItem`) when `TryAcquire` and `Release` from sync manager. `TryAcquire` from sync_manager` calls a new `checkAcquire` method, whilst holding the sync_manager internal golang `sync.Mutex` to check if they are all acquirable before acquiring them. This honors priority. `TryAcquire` also returns the failed lock name in the case of failure to acquire to reduce the number of exported `package sync` methods and complexity outside of `sync`. The interface to the workflow status block has not changed. Reduced the exported types and methods from the sync module as far as possible (lower case instead of upper case). Removed the internal golang sync mutex from `PrioritySemaphore` as all methods are called from `sync_manager.go` when under it's own lock. The alternative was unnecessarily complicating the calls inside semaphore.go. This is faster, but less clean in case someone wants to reuse the PrioritySemaphore type. Renamed the manager in `sync_manager.go` where used: `cm`->`sm` and `concurrencyManager`->`syncManager`. New and updated unit tests. New and updated e2e smoke tests. Signed-off-by: Alan Clucas <[email protected]>
Co-authored-by: Anton Gilgur <[email protected]> Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
cf67c5e
to
8e26e16
Compare
Signed-off-by: Alan Clucas <[email protected]>
Dismissing my review to unblock this. We can iterate on the docs later
I haven't been feeling great the past week, so dismissed my review to unblock this. Can iterate more on docs later as I do have some thoughts on them, but haven't quite had the brainpower to review properly |
/retest |
1 similar comment
/retest |
I wrote up a follow-up docs PR in #13645 which also addresses the immediate user confusion with versions per #13644 et al (I also suddenly started feeling much better on Friday, hence all my contributions this weekend. maybe the new meds have kicked in 🤷 🤞) |
I have a WIP PR for this in #13669. Might want someone here to take that over as some of the logic would be desirable to transfer to 3.6+ as well. It would also be a good place to add deprecation warnings in the logs in 3.6+ |
Fixes #5022
Fixes #11859
This is mostly backwards compatible. It is minorly breaking only in as much as semaphore + mutex at the same time will now actually take both, whereas before it ignored the mutex.
Motivation
As a workflows users I would like to be able to use more than one sync option in a workflow or template.
Modifications
Added
mutexes
andsemaphores
to thesynchronization
block in workflow types as lists. Legacymutex
andsemaphore
kept in and continue to work (will be added to the mutexes/semaphores list) but marked for deprecation.Logic changed to acquire a full list of all synchronization items (
syncItem
) whenTryAcquire
andRelease
from sync manager.TryAcquire
fromsync_manager
calls a newcheckAcquire
method, whilst holding the sync_manager internal golangsync.Mutex
to check if they are all acquirable before acquiring them. This honors priority.TryAcquire
also returns the failed lock name in the case of failure to acquire to reduce the number of exportedpackage sync
methods and complexity outside ofsync
.The interface to the workflow status block has not changed.
Reduced the exported types and methods from the sync module as far as possible (lower case instead of upper case).
Removed the internal golang sync mutex from
PrioritySemaphore
as all methods are called fromsync_manager.go
when under it's own lock. The alternative was unnecessarily complicating the calls insidesemaphore.go
. This is faster, but less clean in case someone wants to reuse the PrioritySemaphore type.Renamed the manager in
sync_manager.go
where used:cm
->sm
andconcurrencyManager
->syncManager
.Synchronization documentation updated-- EDIT: split to #13393Verification
New and updated unit tests.
New and updated e2e smoke tests.
Stacked PR
This is stacked on top of #13393 now.
Signed-off-by: Alan Clucas [email protected]