mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
Latency monitor: specialize delayed aof writes events.
This commit is contained in:
parent
a53c734094
commit
53ae687d59
20
src/aof.c
20
src/aof.c
@ -258,20 +258,32 @@ void flushAppendOnlyFile(int force) {
|
|||||||
redisLog(REDIS_NOTICE,"Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis.");
|
redisLog(REDIS_NOTICE,"Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* If you are following this code path, then we are going to write so
|
|
||||||
* set reset the postponed flush sentinel to zero. */
|
|
||||||
server.aof_flush_postponed_start = 0;
|
|
||||||
|
|
||||||
/* We want to perform a single write. This should be guaranteed atomic
|
/* We want to perform a single write. This should be guaranteed atomic
|
||||||
* at least if the filesystem we are writing is a real physical one.
|
* at least if the filesystem we are writing is a real physical one.
|
||||||
* While this will save us against the server being killed I don't think
|
* While this will save us against the server being killed I don't think
|
||||||
* there is much to do about the whole server stopping for power problems
|
* there is much to do about the whole server stopping for power problems
|
||||||
* or alike */
|
* or alike */
|
||||||
|
|
||||||
latencyStartMonitor(latency);
|
latencyStartMonitor(latency);
|
||||||
nwritten = write(server.aof_fd,server.aof_buf,sdslen(server.aof_buf));
|
nwritten = write(server.aof_fd,server.aof_buf,sdslen(server.aof_buf));
|
||||||
latencyEndMonitor(latency);
|
latencyEndMonitor(latency);
|
||||||
|
/* We want to capture different events for delayed writes:
|
||||||
|
* when the delay happens with a pending fsync, or with a saving child
|
||||||
|
* active, and when the above two conditions are missing.
|
||||||
|
* We also use an additional event name to save all samples which is
|
||||||
|
* useful for graphing / monitoring purposes. */
|
||||||
|
if (server.aof_flush_postponed_start != 0) {
|
||||||
|
latencyAddSampleIfNeeded("aof-write-pending-fsync",latency);
|
||||||
|
} else if (server.aof_child_pid != -1 || server.rdb_child_pid != -1) {
|
||||||
|
latencyAddSampleIfNeeded("aof-write-active-child",latency);
|
||||||
|
} else {
|
||||||
|
latencyAddSampleIfNeeded("aof-write-alone",latency);
|
||||||
|
}
|
||||||
latencyAddSampleIfNeeded("aof-write",latency);
|
latencyAddSampleIfNeeded("aof-write",latency);
|
||||||
|
|
||||||
|
/* We performed the write so reset the postponed flush sentinel to zero. */
|
||||||
|
server.aof_flush_postponed_start = 0;
|
||||||
|
|
||||||
if (nwritten != (signed)sdslen(server.aof_buf)) {
|
if (nwritten != (signed)sdslen(server.aof_buf)) {
|
||||||
static time_t last_write_error_log = 0;
|
static time_t last_write_error_log = 0;
|
||||||
int can_log = 0;
|
int can_log = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user