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
e166abad
Commit
e166abad
authored
Mar 08, 2013
by
antirez
Browse files
Move Redis databases background processing to databasesCron().
parent
aec5ea5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
e166abad
...
...
@@ -790,6 +790,27 @@ void clientsCron(void) {
}
}
/* This function handles 'background' operations we are required to do
* incrementally in Redis databases, such as active key expiring, resizing,
* rehashing. */
void
databasesCron
(
void
)
{
/* Expire a few keys per cycle, only if this is a master.
* On slaves we wait for DEL operations synthesized by the master
* in order to guarantee a strict consistency. */
if
(
server
.
masterhost
==
NULL
)
activeExpireCycle
();
/* We don't want to resize the hash tables while a background saving
* is in progress: the saving child is created using fork() that is
* implemented with a copy-on-write semantic in most modern systems, so
* if we resize the HT while there is the saving child at work actually
* a lot of memory movements in the parent will cause a lot of pages
* copied. */
if
(
server
.
rdb_child_pid
==
-
1
&&
server
.
aof_child_pid
==
-
1
)
{
tryResizeHashTables
();
if
(
server
.
activerehashing
)
incrementallyRehash
();
}
}
/* This is our timer interrupt, called server.hz times per second.
* Here is where we do a number of things that need to be done asynchronously.
* For instance:
...
...
@@ -868,17 +889,6 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
}
}
/* We don't want to resize the hash tables while a background saving
* is in progress: the saving child is created using fork() that is
* implemented with a copy-on-write semantic in most modern systems, so
* if we resize the HT while there is the saving child at work actually
* a lot of memory movements in the parent will cause a lot of pages
* copied. */
if
(
server
.
rdb_child_pid
==
-
1
&&
server
.
aof_child_pid
==
-
1
)
{
tryResizeHashTables
();
if
(
server
.
activerehashing
)
incrementallyRehash
();
}
/* Show information about connected clients */
if
(
!
server
.
sentinel_mode
)
{
run_with_period
(
5000
)
{
...
...
@@ -959,11 +969,6 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
* cron function is called. */
if
(
server
.
aof_flush_postponed_start
)
flushAppendOnlyFile
(
0
);
/* Expire a few keys per cycle, only if this is a master.
* On slaves we wait for DEL operations synthesized by the master
* in order to guarantee a strict consistency. */
if
(
server
.
masterhost
==
NULL
)
activeExpireCycle
();
/* Close clients that need to be closed asynchronous */
freeClientsInAsyncFreeQueue
();
...
...
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