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
8d51fb6a
Commit
8d51fb6a
authored
Dec 30, 2010
by
antirez
Browse files
diskstore cache bug fixing
parent
98a9abb6
Changes
3
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
8d51fb6a
...
@@ -21,6 +21,7 @@ robj *lookupKey(redisDb *db, robj *key) {
...
@@ -21,6 +21,7 @@ robj *lookupKey(redisDb *db, robj *key) {
/* FIXME: change this code to just wait for our object to
/* FIXME: change this code to just wait for our object to
* get out of the IO Job. */
* get out of the IO Job. */
waitEmptyIOJobsQueue
();
waitEmptyIOJobsQueue
();
processAllPendingIOJobs
();
redisAssert
(
val
->
storage
!=
REDIS_DS_SAVING
);
redisAssert
(
val
->
storage
!=
REDIS_DS_SAVING
);
}
}
server
.
stat_keyspace_hits
++
;
server
.
stat_keyspace_hits
++
;
...
...
src/dscache.c
View file @
8d51fb6a
...
@@ -404,16 +404,14 @@ void spawnIOThread(void) {
...
@@ -404,16 +404,14 @@ void spawnIOThread(void) {
server
.
io_active_threads
++
;
server
.
io_active_threads
++
;
}
}
/* We need to wait for the last thread to exit before we are able to
/* Wait that all the pending IO Jobs are processed */
* fork() in order to BGSAVE or BGREWRITEAOF. */
void
waitEmptyIOJobsQueue
(
void
)
{
void
waitEmptyIOJobsQueue
(
void
)
{
while
(
1
)
{
while
(
1
)
{
int
io_processed_len
;
int
io_processed_len
;
lockThreadedIO
();
lockThreadedIO
();
if
(
listLength
(
server
.
io_newjobs
)
==
0
&&
if
(
listLength
(
server
.
io_newjobs
)
==
0
&&
listLength
(
server
.
io_processing
)
==
0
&&
listLength
(
server
.
io_processing
)
==
0
)
server
.
io_active_threads
==
0
)
{
{
unlockThreadedIO
();
unlockThreadedIO
();
return
;
return
;
...
@@ -434,6 +432,21 @@ void waitEmptyIOJobsQueue(void) {
...
@@ -434,6 +432,21 @@ void waitEmptyIOJobsQueue(void) {
}
}
}
}
/* Process all the IO Jobs already completed by threads but still waiting
* processing from the main thread. */
void
processAllPendingIOJobs
(
void
)
{
while
(
1
)
{
int
io_processed_len
;
lockThreadedIO
();
io_processed_len
=
listLength
(
server
.
io_processed
);
unlockThreadedIO
();
if
(
io_processed_len
==
0
)
return
;
vmThreadedIOCompletedJob
(
NULL
,
server
.
io_ready_pipe_read
,
(
void
*
)
0xdeadbeef
,
0
);
}
}
/* This function must be called while with threaded IO locked */
/* This function must be called while with threaded IO locked */
void
queueIOJob
(
iojob
*
j
)
{
void
queueIOJob
(
iojob
*
j
)
{
redisLog
(
REDIS_DEBUG
,
"Queued IO Job %p type %d about key '%s'
\n
"
,
redisLog
(
REDIS_DEBUG
,
"Queued IO Job %p type %d about key '%s'
\n
"
,
...
...
src/redis.h
View file @
8d51fb6a
...
@@ -799,6 +799,7 @@ void unlockThreadedIO(void);
...
@@ -799,6 +799,7 @@ void unlockThreadedIO(void);
void
freeIOJob
(
iojob
*
j
);
void
freeIOJob
(
iojob
*
j
);
void
queueIOJob
(
iojob
*
j
);
void
queueIOJob
(
iojob
*
j
);
void
waitEmptyIOJobsQueue
(
void
);
void
waitEmptyIOJobsQueue
(
void
);
void
processAllPendingIOJobs
(
void
);
void
zunionInterBlockClientOnSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
,
int
argc
,
robj
**
argv
);
void
zunionInterBlockClientOnSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
,
int
argc
,
robj
**
argv
);
void
execBlockClientOnSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
,
int
argc
,
robj
**
argv
);
void
execBlockClientOnSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
,
int
argc
,
robj
**
argv
);
int
blockClientOnSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
);
int
blockClientOnSwappedKeys
(
redisClient
*
c
,
struct
redisCommand
*
cmd
);
...
...
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