persistent storage isn't available due to error "The specified item already exists in the keychain." #23588
Labels
Azure.Identity
bug
This issue requires a change to an existing behavior in the product in order to be resolved.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Milestone
Bug Report
go version
Executing multiple instances of a program on macOS with keychain token caching (
"github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache"
) fails with:This is because the
tryStorage
function is executed many times when many instances of a program are executed concurrently: https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/azidentity/cache/cache.go#L71 Thesync.Once
is obviously not enough to prevent cache from "trying" storage simultaneously from many programs at once.Cache creation not failing.
Execute program with token caching many times in parallel. I think just many
cache.New(nil)
in parallel is needed.I suggest giving an option to disable the
tryStorage
check incache.Options
. I think the change is trivial and seems to work in my environment.Additionally, the
tryStorage
takes ~30ms on M2 MAX so it would be nice to have an option to shave that time from the Go cli.General question: Is the cache safe for concurrent use from multiple programs? e.g. requesting and caching tokens from multiple programs simultaneously on macOS? can keychain be modified concurrently?
The text was updated successfully, but these errors were encountered: