Skip to content

Commit bf5b2d7

Browse files
committed
Fix issue #300
1 parent f660cd9 commit bf5b2d7

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/networking.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,8 @@ void processInputBuffer(client *c, int callFlags) {
23152315
/* Immediately abort if the client is in the middle of something. */
23162316
if (c->flags & CLIENT_BLOCKED) break;
23172317

2318+
if (c->flags & CLIENT_EXECUTING_COMMAND) break;
2319+
23182320
/* Don't process input from the master while there is a busy script
23192321
* condition on the replica. We want just to accumulate the replication
23202322
* stream (instead of replying -BUSY like we do with other clients) and
@@ -2349,13 +2351,16 @@ void processInputBuffer(client *c, int callFlags) {
23492351
if (c->argc == 0) {
23502352
resetClient(c);
23512353
} else {
2354+
c->flags |= CLIENT_EXECUTING_COMMAND;
23522355
/* We are finally ready to execute the command. */
23532356
if (processCommandAndResetClient(c, callFlags) == C_ERR) {
23542357
/* If the client is no longer valid, we avoid exiting this
23552358
* loop and trimming the client buffer later. So we return
23562359
* ASAP in that case. */
2360+
c->flags &= ~CLIENT_EXECUTING_COMMAND;
23572361
return;
23582362
}
2363+
c->flags &= ~CLIENT_EXECUTING_COMMAND;
23592364
}
23602365
}
23612366

src/server.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,8 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT];
441441
#define CLIENT_PENDING_READ (1<<29) /* The client has pending reads and was put
442442
in the list of clients we can read
443443
from. */
444-
#define CLIENT_PENDING_COMMAND (1<<30) /* Used in threaded I/O to signal after
445-
we return single threaded that the
446-
client has already pending commands
447-
to be executed. */
444+
#define CLIENT_EXECUTING_COMMAND (1<<30) /* Used to handle reentrency cases in processCommandWhileBlocked
445+
to ensure we don't process a client already executing */
448446
#define CLIENT_TRACKING (1ULL<<31) /* Client enabled keys tracking in order to
449447
perform client side caching. */
450448
#define CLIENT_TRACKING_BROKEN_REDIR (1ULL<<32) /* Target client is invalid. */

tests/unit/scripting.tcl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,21 @@ start_server {tags {"scripting"}} {
430430
set res
431431
} {102}
432432

433+
test {EVAL with pipelined command (No crash)} {
434+
r flushall
435+
r config set lua-time-limit 1
436+
set rd [redis_deferring_client]
437+
$rd eval {for i=1,1000000 do redis.call('set', i, 'sdfdsfd') end} 0
438+
$rd set testkey foo
439+
$rd get testkey
440+
after 1200
441+
catch {r echo "foo"} err
442+
assert_match {BUSY*} $err
443+
$rd read
444+
$rd close
445+
}
446+
447+
433448
test {EVAL timeout from AOF} {
434449
# generate a long running script that is propagated to the AOF as script
435450
# make sure that the script times out during loading

0 commit comments

Comments
 (0)