From 5a8dccb72874a7bb2d20224a1a53879b0b1e348c Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Fri, 4 Oct 2024 08:57:28 -0700 Subject: [PATCH 1/6] < 1 --- src/CosmosCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CosmosCache.cs b/src/CosmosCache.cs index 1e9acc4..3bcc2f7 100644 --- a/src/CosmosCache.cs +++ b/src/CosmosCache.cs @@ -129,7 +129,7 @@ public byte[] Get(string key) else { double pendingSeconds = (absoluteExpiration - DateTimeOffset.UtcNow).TotalSeconds; - if (pendingSeconds == 0) + if (pendingSeconds < 1) { // Cosmos DB TTL works on seconds granularity and this item has less than a second to live. // Return the content because it does exist, but it will be cleaned up by the TTL shortly after. @@ -231,7 +231,7 @@ public void Refresh(string key) else { double pendingSeconds = (absoluteExpiration - DateTimeOffset.UtcNow).TotalSeconds; - if (pendingSeconds == 0) + if (pendingSeconds < 1) { // Cosmos DB TTL works on seconds granularity and this item has less than a second to live. // Treat it as a cache-miss. From 569730c70f7dd628efff5ce67fcf25988a186928 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Fri, 4 Oct 2024 08:57:38 -0700 Subject: [PATCH 2/6] version bump --- src/CosmosDistributedCache.csproj | 2 +- src/src.generated.sln | 25 +++++++++++++++++++++++++ tests/tests.generated.sln | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/src.generated.sln create mode 100644 tests/tests.generated.sln diff --git a/src/CosmosDistributedCache.csproj b/src/CosmosDistributedCache.csproj index 78beda4..df53912 100644 --- a/src/CosmosDistributedCache.csproj +++ b/src/CosmosDistributedCache.csproj @@ -6,7 +6,7 @@ © Microsoft Corporation. All rights reserved. $([System.DateTime]::Now.ToString(yyyyMMdd)) en-US - 1.6.2 + 1.6.3 preview $(ClientVersion) $(ClientVersion)-$(VersionSuffix) diff --git a/src/src.generated.sln b/src/src.generated.sln new file mode 100644 index 0000000..664539a --- /dev/null +++ b/src/src.generated.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosDistributedCache", "CosmosDistributedCache.csproj", "{AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CE91D04E-B94B-4A77-B09C-1A3D33467617} + EndGlobalSection +EndGlobal diff --git a/tests/tests.generated.sln b/tests/tests.generated.sln new file mode 100644 index 0000000..ab2077a --- /dev/null +++ b/tests/tests.generated.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosDistributedCacheEmulatorTests", "emulator\CosmosDistributedCacheEmulatorTests.csproj", "{CB39FD80-6C7E-419D-AC65-E07132CFA85B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosDistributedCacheTests", "unit\CosmosDistributedCacheTests.csproj", "{71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Release|Any CPU.Build.0 = Release|Any CPU + {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EFB2CCBB-20B1-488E-B86A-2D87E2661FF6} + EndGlobalSection +EndGlobal From 45ae6877bbe27a390662d58716ad11e261906dcb Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Fri, 4 Oct 2024 08:58:44 -0700 Subject: [PATCH 3/6] Bump dependency --- src/CosmosDistributedCache.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CosmosDistributedCache.csproj b/src/CosmosDistributedCache.csproj index df53912..2378e61 100644 --- a/src/CosmosDistributedCache.csproj +++ b/src/CosmosDistributedCache.csproj @@ -6,7 +6,7 @@ © Microsoft Corporation. All rights reserved. $([System.DateTime]::Now.ToString(yyyyMMdd)) en-US - 1.6.3 + 1.7.0 preview $(ClientVersion) $(ClientVersion)-$(VersionSuffix) @@ -40,7 +40,7 @@ - + From d9a3bedf801b0e4418b07fcb3d59d5ea17cd3621 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Fri, 4 Oct 2024 09:01:40 -0700 Subject: [PATCH 4/6] changelog --- changelog.md | 10 ++++++++++ src/src.generated.sln | 25 ------------------------- tests/tests.generated.sln | 31 ------------------------------- 3 files changed, 10 insertions(+), 56 deletions(-) delete mode 100644 src/src.generated.sln delete mode 100644 tests/tests.generated.sln diff --git a/changelog.md b/changelog.md index 0eedc5a..dbc100f 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +## 1.7.0 - 2024-10-04 + +### Added + +- [#72](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Increased SDK dependency version for critical fixes + +### Fixed + +- [#84](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Fix another race condition with less than 1 seconds left on sliding expiration + ## 1.6.2 - 2024-08-30 ### Fixed diff --git a/src/src.generated.sln b/src/src.generated.sln deleted file mode 100644 index 664539a..0000000 --- a/src/src.generated.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosDistributedCache", "CosmosDistributedCache.csproj", "{AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AD63FE12-5B30-47AA-A9C8-3B2D4374A4AD}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CE91D04E-B94B-4A77-B09C-1A3D33467617} - EndGlobalSection -EndGlobal diff --git a/tests/tests.generated.sln b/tests/tests.generated.sln deleted file mode 100644 index ab2077a..0000000 --- a/tests/tests.generated.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.5.002.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosDistributedCacheEmulatorTests", "emulator\CosmosDistributedCacheEmulatorTests.csproj", "{CB39FD80-6C7E-419D-AC65-E07132CFA85B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CosmosDistributedCacheTests", "unit\CosmosDistributedCacheTests.csproj", "{71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CB39FD80-6C7E-419D-AC65-E07132CFA85B}.Release|Any CPU.Build.0 = Release|Any CPU - {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {71AEE1AA-BDD5-42FC-AE6D-D1CA5159531B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {EFB2CCBB-20B1-488E-B86A-2D87E2661FF6} - EndGlobalSection -EndGlobal From ff52d3940c677050e616f92c0418ee9fb1095d32 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Mon, 7 Oct 2024 11:39:29 -0700 Subject: [PATCH 5/6] tests --- tests/unit/CosmosCacheTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/CosmosCacheTests.cs b/tests/unit/CosmosCacheTests.cs index 4a7e096..e834229 100644 --- a/tests/unit/CosmosCacheTests.cs +++ b/tests/unit/CosmosCacheTests.cs @@ -719,7 +719,7 @@ public async Task SlidingExpirationWithAbsoluteExpirationOnReplaceNotFound() public async Task SlidingExpirationWithAbsoluteExpirationOnAlmostExpiredRead() { const int ttlSliding = 20; - const int ttlAbsolute = 500; + const int ttlAbsolute = 900; string etag = "etag"; CosmosCacheSession existingSession = new CosmosCacheSession(); existingSession.SessionKey = "key"; From 30a44a4bf1a2d61d01270e7ec486c4da82736112 Mon Sep 17 00:00:00 2001 From: Matias Quaranta Date: Mon, 7 Oct 2024 13:30:49 -0700 Subject: [PATCH 6/6] changelog fix --- changelog.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index dbc100f..9b21369 100644 --- a/changelog.md +++ b/changelog.md @@ -4,15 +4,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased -## 1.7.0 - 2024-10-04 +## 1.7.0 - 2024-10-08 ### Added -- [#72](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Increased SDK dependency version for critical fixes +- [#85](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Increased SDK dependency version for critical fixes ### Fixed -- [#84](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Fix another race condition with less than 1 seconds left on sliding expiration +- [#85](https://github.com/Azure/Microsoft.Extensions.Caching.Cosmos/pull/85) Fix another race condition with less than 1 seconds left on sliding expiration ## 1.6.2 - 2024-08-30