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
e37efb0d
Commit
e37efb0d
authored
Jan 02, 2011
by
antirez
Browse files
diskstore race condition fixed
parent
133cf28e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dscache.c
View file @
e37efb0d
...
@@ -596,6 +596,11 @@ void cacheScheduleIOAddFlag(redisDb *db, robj *key, long flag) {
...
@@ -596,6 +596,11 @@ void cacheScheduleIOAddFlag(redisDb *db, robj *key, long flag) {
return
;
return
;
}
else
{
}
else
{
long
flags
=
(
long
)
dictGetEntryVal
(
de
);
long
flags
=
(
long
)
dictGetEntryVal
(
de
);
if
(
flags
&
flag
)
{
redisLog
(
REDIS_WARNING
,
"Adding the same flag again: was: %ld, addede: %ld"
,
flags
,
flag
);
redisAssert
(
!
(
flags
&
flag
));
}
flags
|=
flag
;
flags
|=
flag
;
dictGetEntryVal
(
de
)
=
(
void
*
)
flags
;
dictGetEntryVal
(
de
)
=
(
void
*
)
flags
;
}
}
...
@@ -662,6 +667,8 @@ void cacheCron(void) {
...
@@ -662,6 +667,8 @@ void cacheCron(void) {
topush
=
100
-
jobs
;
topush
=
100
-
jobs
;
if
(
topush
<
0
)
topush
=
0
;
if
(
topush
<
0
)
topush
=
0
;
if
(
topush
>
(
signed
)
listLength
(
server
.
cache_io_queue
))
topush
=
listLength
(
server
.
cache_io_queue
);
while
((
ln
=
listFirst
(
server
.
cache_io_queue
))
!=
NULL
)
{
while
((
ln
=
listFirst
(
server
.
cache_io_queue
))
!=
NULL
)
{
ioop
*
op
=
ln
->
value
;
ioop
*
op
=
ln
->
value
;
...
@@ -675,6 +682,23 @@ void cacheCron(void) {
...
@@ -675,6 +682,23 @@ void cacheCron(void) {
struct
dictEntry
*
de
;
struct
dictEntry
*
de
;
robj
*
val
;
robj
*
val
;
/* Don't add a SAVE job in queue if there is already
* a save in progress for the same key. */
if
(
op
->
type
==
REDIS_IO_SAVE
&&
cacheScheduleIOGetFlags
(
op
->
db
,
op
->
key
)
&
REDIS_IO_SAVEINPROG
)
{
/* Move the operation at the end of the list of there
* are other operations. Otherwise break, nothing to do
* here. */
if
(
listLength
(
server
.
cache_io_queue
)
>
1
)
{
listDelNode
(
server
.
cache_io_queue
,
ln
);
listAddNodeTail
(
server
.
cache_io_queue
,
op
);
continue
;
}
else
{
break
;
}
}
redisLog
(
REDIS_DEBUG
,
"Creating IO %s Job for key %s"
,
redisLog
(
REDIS_DEBUG
,
"Creating IO %s Job for key %s"
,
op
->
type
==
REDIS_IO_LOAD
?
"load"
:
"save"
,
op
->
key
->
ptr
);
op
->
type
==
REDIS_IO_LOAD
?
"load"
:
"save"
,
op
->
key
->
ptr
);
...
...
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