Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e03358c0
Unverified
Commit
e03358c0
authored
Jul 17, 2018
by
Salvatore Sanfilippo
Committed by
GitHub
Jul 17, 2018
Browse files
Merge pull request #5135 from oranagra/rare_repl_corruption
fix rare replication stream corruption with disk-based replication
parents
cefe21d2
d5559898
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
e03358c0
...
...
@@ -342,11 +342,13 @@ void addReplyErrorLength(client *c, const char *s, size_t len) {
if
(
!
len
||
s
[
0
]
!=
'-'
)
addReplyString
(
c
,
"-ERR "
,
5
);
addReplyString
(
c
,
s
,
len
);
addReplyString
(
c
,
"
\r\n
"
,
2
);
if
(
c
->
flags
&
CLIENT_MASTER
)
{
if
(
c
->
flags
&
(
CLIENT_MASTER
|
CLIENT_SLAVE
))
{
char
*
to
=
c
->
flags
&
CLIENT_MASTER
?
"master"
:
"slave"
;
char
*
from
=
c
->
flags
&
CLIENT_MASTER
?
"slave"
:
"master"
;
char
*
cmdname
=
c
->
lastcmd
?
c
->
lastcmd
->
name
:
"<unknown>"
;
serverLog
(
LL_WARNING
,
"== CRITICAL == This s
lave
is sending an error "
"to its
master
: '%s' after processing the command "
"'%s'"
,
s
,
cmdname
);
serverLog
(
LL_WARNING
,
"== CRITICAL == This
%
s is sending an error "
"to its
%s
: '%s' after processing the command "
"'%s'"
,
from
,
to
,
s
,
cmdname
);
}
}
...
...
@@ -608,6 +610,7 @@ void addReplySubcommandSyntaxError(client *c) {
* destination client. */
void
copyClientOutputBuffer
(
client
*
dst
,
client
*
src
)
{
listRelease
(
dst
->
reply
);
dst
->
sentlen
=
0
;
dst
->
reply
=
listDup
(
src
->
reply
);
memcpy
(
dst
->
buf
,
src
->
buf
,
src
->
bufpos
);
dst
->
bufpos
=
src
->
bufpos
;
...
...
@@ -1094,7 +1097,7 @@ void resetClient(client *c) {
* with the error and close the connection. */
int
processInlineBuffer
(
client
*
c
)
{
char
*
newline
;
int
argc
,
j
;
int
argc
,
j
,
linefeed_chars
=
1
;
sds
*
argv
,
aux
;
size_t
querylen
;
...
...
@@ -1112,7 +1115,7 @@ int processInlineBuffer(client *c) {
/* Handle the \r\n case. */
if
(
newline
&&
newline
!=
c
->
querybuf
&&
*
(
newline
-
1
)
==
'\r'
)
newline
--
;
newline
--
,
linefeed_chars
++
;
/* Split the input buffer up to the \r\n */
querylen
=
newline
-
(
c
->
querybuf
);
...
...
@@ -1132,7 +1135,7 @@ int processInlineBuffer(client *c) {
c
->
repl_ack_time
=
server
.
unixtime
;
/* Leave data after the first line of the query in the buffer */
sdsrange
(
c
->
querybuf
,
querylen
+
2
,
-
1
);
sdsrange
(
c
->
querybuf
,
querylen
+
linefeed_chars
,
-
1
);
/* Setup argv array on client structure */
if
(
argc
)
{
...
...
src/replication.c
View file @
e03358c0
...
...
@@ -2148,6 +2148,7 @@ void replicationCacheMaster(client *c) {
server
.
master
->
read_reploff
=
server
.
master
->
reploff
;
if
(
c
->
flags
&
CLIENT_MULTI
)
discardTransaction
(
c
);
listEmpty
(
c
->
reply
);
c
->
sentlen
=
0
;
c
->
reply_bytes
=
0
;
c
->
bufpos
=
0
;
resetClient
(
c
);
...
...
src/server.c
View file @
e03358c0
...
...
@@ -2449,8 +2449,13 @@ int processCommand(client *c) {
c
->
cmd
=
c
->
lastcmd
=
lookupCommand
(
c
->
argv
[
0
]
->
ptr
);
if
(
!
c
->
cmd
)
{
flagTransaction
(
c
);
addReplyErrorFormat
(
c
,
"unknown command '%s'"
,
(
char
*
)
c
->
argv
[
0
]
->
ptr
);
sds
args
=
sdsempty
();
int
i
;
for
(
i
=
1
;
i
<
c
->
argc
&&
sdslen
(
args
)
<
128
;
i
++
)
args
=
sdscatprintf
(
args
,
"`%.*s`, "
,
128
-
(
int
)
sdslen
(
args
),
(
char
*
)
c
->
argv
[
i
]
->
ptr
);
addReplyErrorFormat
(
c
,
"unknown command `%s`, with args beginning with: %s"
,
(
char
*
)
c
->
argv
[
0
]
->
ptr
,
args
);
sdsfree
(
args
);
return
C_OK
;
}
else
if
((
c
->
cmd
->
arity
>
0
&&
c
->
cmd
->
arity
!=
c
->
argc
)
||
(
c
->
argc
<
-
c
->
cmd
->
arity
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment