Skip to content

Commit ca2700d

Browse files
committed
reapply bits missed from complex merge
1 parent 13ec91b commit ca2700d

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/StackExchange.Redis/PhysicalConnection.Read.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private async Task ReadAllAsync(CancellationToken cancellationToken)
4949
_readStatus = ReadStatus.TryParseResult;
5050
}
5151
// another formatter glitch
52-
while (CommitAndParseFrames(read));
52+
while (CommitAndParseFrames(read) && !ForceReconnect);
5353

5454
_readStatus = ReadStatus.ProcessBufferComplete;
5555

@@ -74,6 +74,8 @@ private async Task ReadAllAsync(CancellationToken cancellationToken)
7474
}
7575
}
7676

77+
private bool ForceReconnect => BridgeCouldBeNull?.NeedsReconnect == true;
78+
7779
private static byte[]? SharedNoLease;
7880

7981
private CycleBuffer _readBuffer;

tests/StackExchange.Redis.Tests/InProcessTestServer.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ public ConfigurationOptions GetClientConfig(bool withPubSub = false)
4242
commands.Remove(nameof(RedisCommand.PUBLISH));
4343
commands.Remove(nameof(RedisCommand.SPUBLISH));
4444
}
45-
// transactions don't work yet
46-
commands.Remove(nameof(RedisCommand.MULTI));
47-
commands.Remove(nameof(RedisCommand.EXEC));
48-
commands.Remove(nameof(RedisCommand.DISCARD));
49-
commands.Remove(nameof(RedisCommand.WATCH));
50-
commands.Remove(nameof(RedisCommand.UNWATCH));
5145

5246
var config = new ConfigurationOptions
5347
{

tests/StackExchange.Redis.Tests/TestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace StackExchange.Redis.Tests;
1616

1717
public abstract class TestBase : IDisposable
1818
{
19-
private ITestOutputHelper Output { get; }
19+
protected ITestOutputHelper Output { get; }
2020
protected TextWriterOutputHelper Writer { get; }
2121
protected virtual string GetConfiguration()
2222
{

toys/StackExchange.Redis.Server/RespServer.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ public async Task RunClientAsync(IDuplexPipe pipe, RedisServer.Node node = null,
294294
{
295295
// process a completed request
296296
RedisRequest request = new(buffer.Slice(0, consumed), ref commandLease);
297+
request = request.WithClient(client);
297298
var response = Execute(client, request);
299+
client.ResetAfterRequest();
300+
298301
await WriteResponseAsync(client, pipe.Output, response, client.Protocol);
299302

300303
// advance the buffer to account for the message we just read
@@ -529,10 +532,14 @@ public virtual TypedRedisValue Execute(RedisClient client, in RedisRequest reque
529532
if (result.IsError) Interlocked.Increment(ref _totalErrorCount);
530533
return result;
531534
}
532-
catch (KeyMovedException moved) when (GetNode(moved.HashSlot) is { } node)
535+
catch (KeyMovedException moved)
533536
{
534-
OnMoved(client, moved.HashSlot, node);
535-
return TypedRedisValue.Error($"MOVED {moved.HashSlot} {node.Host}:{node.Port}");
537+
if (GetNode(moved.HashSlot) is { } node)
538+
{
539+
OnMoved(client, moved.HashSlot, node);
540+
return TypedRedisValue.Error($"MOVED {moved.HashSlot} {node.Host}:{node.Port}");
541+
}
542+
return TypedRedisValue.Error($"ERR key has been migrated from slot {moved.HashSlot}, but the new owner is unknown");
536543
}
537544
catch (CrossSlotException)
538545
{

0 commit comments

Comments
 (0)