Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ef8bc13d
Commit
ef8bc13d
authored
Jan 24, 2011
by
antirez
Browse files
Merge branch '2.2' of github.com:antirez/redis into 2.2
parents
0ffeadd2
db0e263b
Changes
4
Show whitespace changes
Inline
Side-by-side
00-RELEASENOTES
View file @
ef8bc13d
...
@@ -11,7 +11,7 @@ for 2.0.
...
@@ -11,7 +11,7 @@ for 2.0.
What's new in Redis 2.1.10 (2.2 Release Candidate 3)
What's new in Redis 2.1.10 (2.2 Release Candidate 3)
====================================================
====================================================
Redis 2.2 RC3 is a bug fix and minor enhancements
featur
e:
Redis 2.2 RC3 is a bug fix and minor enhancements
releas
e:
* Solaris fixes
* Solaris fixes
* Fixes and improvements for redis-benchmark
* Fixes and improvements for redis-benchmark
...
...
src/networking.c
View file @
ef8bc13d
...
@@ -498,7 +498,6 @@ void freeClient(redisClient *c) {
...
@@ -498,7 +498,6 @@ void freeClient(redisClient *c) {
/* Case 2: we lost the connection with the master. */
/* Case 2: we lost the connection with the master. */
if
(
c
->
flags
&
REDIS_MASTER
)
{
if
(
c
->
flags
&
REDIS_MASTER
)
{
server
.
master
=
NULL
;
server
.
master
=
NULL
;
/* FIXME */
server
.
replstate
=
REDIS_REPL_CONNECT
;
server
.
replstate
=
REDIS_REPL_CONNECT
;
/* Since we lost the connection with the master, we should also
/* Since we lost the connection with the master, we should also
* close the connection with all our slaves if we have any, so
* close the connection with all our slaves if we have any, so
...
...
src/redis.c
View file @
ef8bc13d
...
@@ -516,7 +516,7 @@ void updateLRUClock(void) {
...
@@ -516,7 +516,7 @@ void updateLRUClock(void) {
}
}
int
serverCron
(
struct
aeEventLoop
*
eventLoop
,
long
long
id
,
void
*
clientData
)
{
int
serverCron
(
struct
aeEventLoop
*
eventLoop
,
long
long
id
,
void
*
clientData
)
{
int
j
,
loops
=
server
.
cronloops
++
;
int
j
,
loops
=
server
.
cronloops
;
REDIS_NOTUSED
(
eventLoop
);
REDIS_NOTUSED
(
eventLoop
);
REDIS_NOTUSED
(
id
);
REDIS_NOTUSED
(
id
);
REDIS_NOTUSED
(
clientData
);
REDIS_NOTUSED
(
clientData
);
...
@@ -645,6 +645,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
...
@@ -645,6 +645,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
* to detect transfer failures. */
* to detect transfer failures. */
if
(
!
(
loops
%
10
))
replicationCron
();
if
(
!
(
loops
%
10
))
replicationCron
();
server
.
cronloops
++
;
return
100
;
return
100
;
}
}
...
...
src/replication.c
View file @
ef8bc13d
...
@@ -328,6 +328,12 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
...
@@ -328,6 +328,12 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
buf
+
1
);
buf
+
1
);
replicationAbortSyncTransfer
();
replicationAbortSyncTransfer
();
return
;
return
;
}
else
if
(
buf
[
0
]
==
'\0'
)
{
/* At this stage just a newline works as a PING in order to take
* the connection live. So we refresh our last interaction
* timestamp. */
server
.
repl_transfer_lastio
=
time
(
NULL
);
return
;
}
else
if
(
buf
[
0
]
!=
'$'
)
{
}
else
if
(
buf
[
0
]
!=
'$'
)
{
redisLog
(
REDIS_WARNING
,
"Bad protocol from MASTER, the first byte is not '$', are you sure the host and port are right?"
);
redisLog
(
REDIS_WARNING
,
"Bad protocol from MASTER, the first byte is not '$', are you sure the host and port are right?"
);
replicationAbortSyncTransfer
();
replicationAbortSyncTransfer
();
...
@@ -488,17 +494,26 @@ void slaveofCommand(redisClient *c) {
...
@@ -488,17 +494,26 @@ void slaveofCommand(redisClient *c) {
/* --------------------------- REPLICATION CRON ---------------------------- */
/* --------------------------- REPLICATION CRON ---------------------------- */
#define REDIS_REPL_TRANSFER_TIMEOUT 60
#define REDIS_REPL_TIMEOUT 60
#define REDIS_REPL_PING_SLAVE_PERIOD 10
void
replicationCron
(
void
)
{
void
replicationCron
(
void
)
{
/* Bulk transfer I/O timeout? */
/* Bulk transfer I/O timeout? */
if
(
server
.
masterhost
&&
server
.
replstate
==
REDIS_REPL_TRANSFER
&&
if
(
server
.
masterhost
&&
server
.
replstate
==
REDIS_REPL_TRANSFER
&&
(
time
(
NULL
)
-
server
.
repl_transfer_lastio
)
>
REDIS_REPL_
TRANSFER_
TIMEOUT
)
(
time
(
NULL
)
-
server
.
repl_transfer_lastio
)
>
REDIS_REPL_TIMEOUT
)
{
{
redisLog
(
REDIS_WARNING
,
"Timeout receiving bulk data from MASTER..."
);
redisLog
(
REDIS_WARNING
,
"Timeout receiving bulk data from MASTER..."
);
replicationAbortSyncTransfer
();
replicationAbortSyncTransfer
();
}
}
/* Timed out master when we are an already connected slave? */
if
(
server
.
masterhost
&&
server
.
replstate
==
REDIS_REPL_CONNECTED
&&
(
time
(
NULL
)
-
server
.
master
->
lastinteraction
)
>
REDIS_REPL_TIMEOUT
)
{
redisLog
(
REDIS_WARNING
,
"MASTER time out: no data nor PING received..."
);
freeClient
(
server
.
master
);
}
/* Check if we should connect to a MASTER */
/* Check if we should connect to a MASTER */
if
(
server
.
replstate
==
REDIS_REPL_CONNECT
)
{
if
(
server
.
replstate
==
REDIS_REPL_CONNECT
)
{
redisLog
(
REDIS_NOTICE
,
"Connecting to MASTER..."
);
redisLog
(
REDIS_NOTICE
,
"Connecting to MASTER..."
);
...
@@ -507,4 +522,33 @@ void replicationCron(void) {
...
@@ -507,4 +522,33 @@ void replicationCron(void) {
if
(
server
.
appendonly
)
rewriteAppendOnlyFileBackground
();
if
(
server
.
appendonly
)
rewriteAppendOnlyFileBackground
();
}
}
}
}
/* If we have attached slaves, PING them from time to time.
* So slaves can implement an explicit timeout to masters, and will
* be able to detect a link disconnection even if the TCP connection
* will not actually go down. */
if
(
!
(
server
.
cronloops
%
(
REDIS_REPL_PING_SLAVE_PERIOD
*
10
)))
{
listIter
li
;
listNode
*
ln
;
listRewind
(
server
.
slaves
,
&
li
);
while
((
ln
=
listNext
(
&
li
)))
{
redisClient
*
slave
=
ln
->
value
;
/* Don't ping slaves that are in the middle of a bulk transfer
* with the master for first synchronization. */
if
(
slave
->
replstate
==
REDIS_REPL_SEND_BULK
)
continue
;
if
(
slave
->
replstate
==
REDIS_REPL_ONLINE
)
{
/* If the slave is online send a normal ping */
addReplySds
(
slave
,
sdsnew
(
"PING
\r\n
"
));
}
else
{
/* Otherwise we are in the pre-synchronization stage.
* Just a newline will do the work of refreshing the
* connection last interaction time, and at the same time
* we'll be sure that being a single char there are no
* short-write problems. */
write
(
slave
->
fd
,
"
\n
"
,
1
);
}
}
}
}
}
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