Skip to content

Commit cf4d08d

Browse files
authored
server: Exit consume-redis-stream loop on error (#5948)
* server: Exit consume-redis-stream loop on error Recently a yield was added to the consume-redis-stream loop. It is possible that when the fiber is scheduled again, things have changed (likely because the redis acks fiber caused a shutdown of the socket). If so we will exit from the loop instead of trying to read from a possibly closed socket. Signed-off-by: Abhijat Malviya <[email protected]>
1 parent 85f21b6 commit cf4d08d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/server/replica.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,17 @@ error_code Replica::ConsumeRedisStream() {
704704
ThisFiber::Yield();
705705
}
706706

707+
// If the acks-fb or something else triggered a shutdown, then do not attempt to read from the
708+
// stream.
709+
if (!exec_st_.IsRunning()) {
710+
DCHECK(exec_st_.IsError());
711+
LOG_REPL_ERROR("Stopping stream consumer in phase "
712+
<< GetCurrentPhase()
713+
<< " because of external error: " << exec_st_.GetError().Format());
714+
acks_fb_.JoinIfNeeded();
715+
return exec_st_.GetError();
716+
}
717+
707718
auto response = ReadRespReply(&io_buf, /*copy_msg=*/false);
708719
if (!response.has_value()) {
709720
LOG_REPL_ERROR("Error in Redis Stream at phase "

0 commit comments

Comments
 (0)