Skip to content

Atomic: avoid race conditions modifying dictionaries#2981

Merged
NachoSoto merged 1 commit into
mainfrom
atomic-modify-append
Aug 9, 2023
Merged

Atomic: avoid race conditions modifying dictionaries#2981
NachoSoto merged 1 commit into
mainfrom
atomic-modify-append

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

Using += on value is doing a separate read + write, instead of modifying the value atomically.

@NachoSoto NachoSoto requested a review from a team August 7, 2023 21:22
@codecov

codecov Bot commented Aug 7, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2981 (7920b54) into main (bb4b1c4) will decrease coverage by 0.12%.
The diff coverage is 100.00%.

❗ Current head 7920b54 differs from pull request most recent head 3717f4d. Consider uploading reports for the commit 3717f4d to get more accurate results

@@            Coverage Diff             @@
##             main    #2981      +/-   ##
==========================================
- Coverage   86.71%   86.60%   -0.12%     
==========================================
  Files         218      217       -1     
  Lines       15623    15531      -92     
==========================================
- Hits        13547    13450      -97     
- Misses       2076     2081       +5     
Files Changed Coverage Δ
Sources/Purchasing/CachingProductsManager.swift 95.32% <100.00%> (ø)
...g/CachingTrialOrIntroPriceEligibilityChecker.swift 96.29% <100.00%> (ø)

... and 16 files with indirect coverage changes

Base automatically changed from caching-products-duplicate-products to main August 9, 2023 13:16
@NachoSoto NachoSoto enabled auto-merge (squash) August 9, 2023 13:24
Using `+=` on `value` is doing a separate read + write, instead of modifying the value atomically.
@NachoSoto NachoSoto force-pushed the atomic-modify-append branch from 7920b54 to 3717f4d Compare August 9, 2023 14:18
@NachoSoto NachoSoto merged commit 24c398f into main Aug 9, 2023
@NachoSoto NachoSoto deleted the atomic-modify-append branch August 9, 2023 15:14
NachoSoto added a commit that referenced this pull request Aug 9, 2023
_This release is compatible with Xcode 15 beta 6 and visionOS beta 3_

### Bugfixes
* `visionOS`: support for `Xcode 15 beta 6` (#2989) via NachoSoto
(@NachoSoto)
* `CachingProductsManager`: avoid crash when caching different products
with same identifier (#2979) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator`: disambiguate transactions from the queue
(#2890) via NachoSoto (@NachoSoto)
### Performance Improvements
* `StoreKit2TransactionListener`: handle transactions asynchronously
(#2910) via NachoSoto (@NachoSoto)
### Other Changes
* `Atomic`: avoid race conditions modifying dictionaries (#2981) via
NachoSoto (@NachoSoto)
* `Logging`: avoid logging "updating offerings" when request is cached
(#2904) via NachoSoto (@NachoSoto)
* `StoreKit2TransactionListener`: converted into an `actor` (#2909) via
NachoSoto (@NachoSoto)
* `Integration Tests`: added more observer mode tests (#2905) via
NachoSoto (@NachoSoto)
* Created `PostedTransactionCache` (#2911) via NachoSoto (@NachoSoto)
* `IntroEligibility`: changed products to `Set<String>` (#2976) via
NachoSoto (@NachoSoto)
* `AdServices`: Rename `postAdServicesTokenIfNeeded()` to
`postAdServicesTokenOncePerInstallIfNeeded()` (#2968) via Josh Holtz
(@joshdholtz)
* `SK1StoreProduct`: changed `productType` warning to debug (#2957) via
NachoSoto (@NachoSoto)
* `PrivacyInfo.xcprivacy`: added `UserDefaults` to access API types
(#2913) via NachoSoto (@NachoSoto)
* `Integration Tests`: new test to verify that SK1 purchases don't leave
SK2 unfinished transactions (#2906) via NachoSoto (@NachoSoto)
* `Logging`: log entire cache key with verbose logs (#2888) via
NachoSoto (@NachoSoto)
* `StoreProduct`: added test covering warning log (#2897) via NachoSoto
(@NachoSoto)
* `CustomEntitlementComputation`: use custom API key (#2879) via Toni
Rico (@tonidero)
* `CachingProductsManager`: removed duplicate log and added tests
(#2898) via NachoSoto (@NachoSoto)
* `Xcode 15 beta 5`: fixed test compilation (#2885) via NachoSoto
(@NachoSoto)

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
MarkVillacampa pushed a commit that referenced this pull request Sep 6, 2023
_This release is compatible with Xcode 15 beta 6 and visionOS beta 3_

### Bugfixes
* `visionOS`: support for `Xcode 15 beta 6` (#2989) via NachoSoto
(@NachoSoto)
* `CachingProductsManager`: avoid crash when caching different products
with same identifier (#2979) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator`: disambiguate transactions from the queue
(#2890) via NachoSoto (@NachoSoto)
### Performance Improvements
* `StoreKit2TransactionListener`: handle transactions asynchronously
(#2910) via NachoSoto (@NachoSoto)
### Other Changes
* `Atomic`: avoid race conditions modifying dictionaries (#2981) via
NachoSoto (@NachoSoto)
* `Logging`: avoid logging "updating offerings" when request is cached
(#2904) via NachoSoto (@NachoSoto)
* `StoreKit2TransactionListener`: converted into an `actor` (#2909) via
NachoSoto (@NachoSoto)
* `Integration Tests`: added more observer mode tests (#2905) via
NachoSoto (@NachoSoto)
* Created `PostedTransactionCache` (#2911) via NachoSoto (@NachoSoto)
* `IntroEligibility`: changed products to `Set<String>` (#2976) via
NachoSoto (@NachoSoto)
* `AdServices`: Rename `postAdServicesTokenIfNeeded()` to
`postAdServicesTokenOncePerInstallIfNeeded()` (#2968) via Josh Holtz
(@joshdholtz)
* `SK1StoreProduct`: changed `productType` warning to debug (#2957) via
NachoSoto (@NachoSoto)
* `PrivacyInfo.xcprivacy`: added `UserDefaults` to access API types
(#2913) via NachoSoto (@NachoSoto)
* `Integration Tests`: new test to verify that SK1 purchases don't leave
SK2 unfinished transactions (#2906) via NachoSoto (@NachoSoto)
* `Logging`: log entire cache key with verbose logs (#2888) via
NachoSoto (@NachoSoto)
* `StoreProduct`: added test covering warning log (#2897) via NachoSoto
(@NachoSoto)
* `CustomEntitlementComputation`: use custom API key (#2879) via Toni
Rico (@tonidero)
* `CachingProductsManager`: removed duplicate log and added tests
(#2898) via NachoSoto (@NachoSoto)
* `Xcode 15 beta 5`: fixed test compilation (#2885) via NachoSoto
(@NachoSoto)

---------

Co-authored-by: NachoSoto <ignaciosoto90@gmail.com>
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.

2 participants