fix(kernel): package cache fails under parallelism #4215
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The package cache mechanism that was turned on by default in #4181 works in theory under parallelism, but not in practice.
Typically the CDK CLI will prevent CDK apps from running in parallel, but Python testing frameworks like
tox
use subprocess parallelism to speed up test runs, leading to the jsii imports being executed at the same time.Since jsii is sync, the locking needs to be sync. The sync locking feature of the
lockfile
library doesn't have wait support (for good reason), and so when a lock is already acquired by another process it quickly burns through its 12 retries in a hot loop, and then exits with an error.Two changes to address this:
Atomics.wait()
to get a synchronous sleeping primitive; sincelockSync
doesn't support synchronous sleep, we build our own retry loop with synchronous sleep aroundlockSync
.Fixes #4207.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.