Skip to content

Commit

Permalink
Fix dequeue script timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Jul 13, 2022
1 parent dce30dc commit 0cc04f6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="MinVer" Version="4.0.0" PrivateAssets="All" />
<PackageReference Include="MinVer" Version="4.1.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Foundatio.Redis/Foundatio.Redis.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ItemGroup>
<PackageReference Include="Foundatio" Version="10.5.1-alpha.0.12" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
<ProjectReference Include="..\..\..\Foundatio\src\Foundatio\Foundatio.csproj" Condition="'$(ReferenceFoundatioSource)' == 'true'" />
<PackageReference Include="StackExchange.Redis" Version="2.6.45" />
<PackageReference Include="StackExchange.Redis" Version="2.6.48" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\*.lua" />
Expand Down
2 changes: 1 addition & 1 deletion src/Foundatio.Redis/Queues/RedisQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private async Task<RedisValue> DequeueIdAsync(CancellationToken linkedCancellati
workListName = _workListName,
queueName = _options.Name,
now,
timeout = timeout.TotalSeconds
timeout = timeout.TotalMilliseconds
}).AnyContext();
return result.ToString();
}, 3, TimeSpan.FromMilliseconds(100), linkedCancellationToken, _logger).AnyContext();
Expand Down
5 changes: 5 additions & 0 deletions tests/Foundatio.Redis.Tests/Locks/RedisLockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ protected override ILockProvider GetLockProvider() {
return new CacheLockProvider(_cache, _messageBus, Log);
}

[Fact]
public override Task CanAcquireLocksInParallel() {
return base.CanAcquireLocksInParallel();
}

[Fact]
public override Task CanAcquireAndReleaseLockAsync() {
return base.CanAcquireAndReleaseLockAsync();
Expand Down
11 changes: 11 additions & 0 deletions tests/Foundatio.Redis.Tests/Queues/RedisQueueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public async Task VerifyCacheKeysAreCorrect() {

_logger.LogInformation("-----");

Assert.False(await db.KeyExistsAsync("q:SimpleWorkItem:" + id + ":renewed"));
var workItem = await queue.DequeueAsync();
Assert.True(await db.KeyExistsAsync("q:SimpleWorkItem:" + id));
Assert.Equal(0, await db.ListLengthAsync($"{listPrefix}:in"));
Expand All @@ -199,6 +200,16 @@ public async Task VerifyCacheKeysAreCorrect() {
Assert.True(await db.KeyExistsAsync("q:SimpleWorkItem:" + id + ":dequeued"));
Assert.Equal(5, await muxer.CountAllKeysAsync());

await Task.Delay(TimeSpan.FromSeconds(4));

Assert.True(await db.KeyExistsAsync("q:SimpleWorkItem:" + id));
Assert.Equal(0, await db.ListLengthAsync($"{listPrefix}:in"));
Assert.Equal(1, await db.ListLengthAsync($"{listPrefix}:work"));
Assert.True(await db.KeyExistsAsync("q:SimpleWorkItem:" + id + ":enqueued"));
Assert.True(await db.KeyExistsAsync("q:SimpleWorkItem:" + id + ":renewed"));
Assert.True(await db.KeyExistsAsync("q:SimpleWorkItem:" + id + ":dequeued"));
Assert.Equal(5, await muxer.CountAllKeysAsync());

_logger.LogInformation("-----");

await workItem.CompleteAsync();
Expand Down

0 comments on commit 0cc04f6

Please sign in to comment.