diff --git a/src/blocked.c b/src/blocked.c index acea59fd07..85ef9170a0 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -61,7 +61,7 @@ */ #include "server.h" -#include "heavyloadlog.h" +#include "slowlog.h" #include "latency.h" #include "monotonic.h" diff --git a/src/commands.def b/src/commands.def index c5f038c4ef..12a63e9347 100644 --- a/src/commands.def +++ b/src/commands.def @@ -6722,10 +6722,10 @@ const char *FATLOG_RESET_Tips[] = { /* FATLOG command table */ struct COMMAND_STRUCT FATLOG_Subcommands[] = { -{MAKE_CMD("get","Returns the fat log's entries.","O(N) where N is the number of entries returned","7.2.5",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_GET_History,0,FATLOG_GET_Tips,2,heavyLoadLogCommand,-2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,FATLOG_GET_Keyspecs,0,NULL,1),.args=FATLOG_GET_Args}, -{MAKE_CMD("help","Show helpful text about the different subcommands","O(1)","7.2.5",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_HELP_History,0,FATLOG_HELP_Tips,0,heavyLoadLogCommand,2,CMD_LOADING|CMD_STALE,0,FATLOG_HELP_Keyspecs,0,NULL,0)}, -{MAKE_CMD("len","Returns the number of entries in the fat log.","O(1)","7.2.5",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_LEN_History,0,FATLOG_LEN_Tips,3,heavyLoadLogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,FATLOG_LEN_Keyspecs,0,NULL,0)}, -{MAKE_CMD("reset","Clears all entries from the fat log.","O(N) where N is the number of entries in the fatlog","7.2.5",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_RESET_History,0,FATLOG_RESET_Tips,2,heavyLoadLogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,FATLOG_RESET_Keyspecs,0,NULL,0)}, +{MAKE_CMD("get","Returns the fat log's entries.","O(N) where N is the number of entries returned","8.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_GET_History,0,FATLOG_GET_Tips,2,slowlogCommand,-2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,FATLOG_GET_Keyspecs,0,NULL,1),.args=FATLOG_GET_Args}, +{MAKE_CMD("help","Show helpful text about the different subcommands","O(1)","8.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_HELP_History,0,FATLOG_HELP_Tips,0,slowlogCommand,2,CMD_LOADING|CMD_STALE,0,FATLOG_HELP_Keyspecs,0,NULL,0)}, +{MAKE_CMD("len","Returns the number of entries in the fat log.","O(1)","8.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_LEN_History,0,FATLOG_LEN_Tips,3,slowlogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,FATLOG_LEN_Keyspecs,0,NULL,0)}, +{MAKE_CMD("reset","Clears all entries from the fat log.","O(N) where N is the number of entries in the fatlog","8.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_RESET_History,0,FATLOG_RESET_Tips,2,slowlogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,FATLOG_RESET_Keyspecs,0,NULL,0)}, {0} }; @@ -7700,10 +7700,10 @@ const char *SLOWLOG_RESET_Tips[] = { /* SLOWLOG command table */ struct COMMAND_STRUCT SLOWLOG_Subcommands[] = { -{MAKE_CMD("get","Returns the slow log's entries.","O(N) where N is the number of entries returned","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_GET_History,1,SLOWLOG_GET_Tips,2,heavyLoadLogCommand,-2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,SLOWLOG_GET_Keyspecs,0,NULL,1),.args=SLOWLOG_GET_Args}, -{MAKE_CMD("help","Show helpful text about the different subcommands","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_HELP_History,0,SLOWLOG_HELP_Tips,0,heavyLoadLogCommand,2,CMD_LOADING|CMD_STALE,0,SLOWLOG_HELP_Keyspecs,0,NULL,0)}, -{MAKE_CMD("len","Returns the number of entries in the slow log.","O(1)","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_LEN_History,0,SLOWLOG_LEN_Tips,3,heavyLoadLogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,SLOWLOG_LEN_Keyspecs,0,NULL,0)}, -{MAKE_CMD("reset","Clears all entries from the slow log.","O(N) where N is the number of entries in the slowlog","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_RESET_History,0,SLOWLOG_RESET_Tips,2,heavyLoadLogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,SLOWLOG_RESET_Keyspecs,0,NULL,0)}, +{MAKE_CMD("get","Returns the slow log's entries.","O(N) where N is the number of entries returned","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_GET_History,1,SLOWLOG_GET_Tips,2,slowlogCommand,-2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,SLOWLOG_GET_Keyspecs,0,NULL,1),.args=SLOWLOG_GET_Args}, +{MAKE_CMD("help","Show helpful text about the different subcommands","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_HELP_History,0,SLOWLOG_HELP_Tips,0,slowlogCommand,2,CMD_LOADING|CMD_STALE,0,SLOWLOG_HELP_Keyspecs,0,NULL,0)}, +{MAKE_CMD("len","Returns the number of entries in the slow log.","O(1)","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_LEN_History,0,SLOWLOG_LEN_Tips,3,slowlogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,SLOWLOG_LEN_Keyspecs,0,NULL,0)}, +{MAKE_CMD("reset","Clears all entries from the slow log.","O(N) where N is the number of entries in the slowlog","2.2.12",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,SLOWLOG_RESET_History,0,SLOWLOG_RESET_Tips,2,slowlogCommand,2,CMD_ADMIN|CMD_LOADING|CMD_STALE,0,SLOWLOG_RESET_Keyspecs,0,NULL,0)}, {0} }; @@ -10914,7 +10914,7 @@ struct COMMAND_STRUCT serverCommandTable[] = { {MAKE_CMD("dbsize","Returns the number of keys in the database.","O(1)","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,DBSIZE_History,0,DBSIZE_Tips,2,dbsizeCommand,1,CMD_READONLY|CMD_FAST,ACL_CATEGORY_KEYSPACE,DBSIZE_Keyspecs,0,NULL,0)}, {MAKE_CMD("debug","A container for debugging commands.","Depends on subcommand.","1.0.0",CMD_DOC_SYSCMD,NULL,NULL,"server",COMMAND_GROUP_SERVER,DEBUG_History,0,DEBUG_Tips,0,debugCommand,-2,CMD_ADMIN|CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_PROTECTED,0,DEBUG_Keyspecs,0,NULL,0)}, {MAKE_CMD("failover","Starts a coordinated failover from a server to one of its replicas.","O(1)","6.2.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FAILOVER_History,0,FAILOVER_Tips,0,failoverCommand,-1,CMD_ADMIN|CMD_NOSCRIPT|CMD_STALE,0,FAILOVER_Keyspecs,0,NULL,3),.args=FAILOVER_Args}, -{MAKE_CMD("fatlog","A container for fat log commands.","Depends on subcommand.","7.2.5",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_History,0,FATLOG_Tips,0,NULL,-2,0,0,FATLOG_Keyspecs,0,NULL,0),.subcommands=FATLOG_Subcommands}, +{MAKE_CMD("fatlog","A container for fat log commands.","Depends on subcommand.","8.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FATLOG_History,0,FATLOG_Tips,0,NULL,-2,0,0,FATLOG_Keyspecs,0,NULL,0),.subcommands=FATLOG_Subcommands}, {MAKE_CMD("flushall","Removes all keys from all databases.","O(N) where N is the total number of keys in all databases","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FLUSHALL_History,2,FLUSHALL_Tips,2,flushallCommand,-1,CMD_WRITE,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,FLUSHALL_Keyspecs,0,NULL,1),.args=FLUSHALL_Args}, {MAKE_CMD("flushdb","Remove all keys from the current database.","O(N) where N is the number of keys in the selected database","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,FLUSHDB_History,2,FLUSHDB_Tips,2,flushdbCommand,-1,CMD_WRITE,ACL_CATEGORY_KEYSPACE|ACL_CATEGORY_DANGEROUS,FLUSHDB_Keyspecs,0,NULL,1),.args=FLUSHDB_Args}, {MAKE_CMD("info","Returns information and statistics about the server.","O(1)","1.0.0",CMD_DOC_NONE,NULL,NULL,"server",COMMAND_GROUP_SERVER,INFO_History,1,INFO_Tips,3,infoCommand,-1,CMD_LOADING|CMD_STALE|CMD_SENTINEL,ACL_CATEGORY_DANGEROUS,INFO_Keyspecs,0,NULL,1),.args=INFO_Args}, @@ -11031,7 +11031,7 @@ struct COMMAND_STRUCT serverCommandTable[] = { {MAKE_CMD("substr","Returns a substring from a string value.","O(N) where N is the length of the returned string. The complexity is ultimately determined by the returned length, but because creating a substring from an existing string is very cheap, it can be considered O(1) for small strings.","1.0.0",CMD_DOC_DEPRECATED,"`GETRANGE`","2.0.0","string",COMMAND_GROUP_STRING,SUBSTR_History,0,SUBSTR_Tips,0,getrangeCommand,4,CMD_READONLY,ACL_CATEGORY_STRING,SUBSTR_Keyspecs,1,NULL,3),.args=SUBSTR_Args}, /* transactions */ {MAKE_CMD("discard","Discards a transaction.","O(N), when N is the number of queued commands","2.0.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,DISCARD_History,0,DISCARD_Tips,0,discardCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,DISCARD_Keyspecs,0,NULL,0)}, -{MAKE_CMD("exec","Executes all commands in a transaction.","Depends on commands in the transaction","1.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,EXEC_History,0,EXEC_Tips,0,execCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SKIP_SLOWLOG|CMD_SKIP_FATLOG,ACL_CATEGORY_TRANSACTION,EXEC_Keyspecs,0,NULL,0)}, +{MAKE_CMD("exec","Executes all commands in a transaction.","Depends on commands in the transaction","1.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,EXEC_History,0,EXEC_Tips,0,execCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_SKIP_SLOWLOG,ACL_CATEGORY_TRANSACTION,EXEC_Keyspecs,0,NULL,0)}, {MAKE_CMD("multi","Starts a transaction.","O(1)","1.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,MULTI_History,0,MULTI_Tips,0,multiCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,MULTI_Keyspecs,0,NULL,0)}, {MAKE_CMD("unwatch","Forgets about watched keys of a transaction.","O(1)","2.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,UNWATCH_History,0,UNWATCH_Tips,0,unwatchCommand,1,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,UNWATCH_Keyspecs,0,NULL,0)}, {MAKE_CMD("watch","Monitors changes to keys to determine the execution of a transaction.","O(1) for every key.","2.2.0",CMD_DOC_NONE,NULL,NULL,"transactions",COMMAND_GROUP_TRANSACTIONS,WATCH_History,0,WATCH_Tips,0,watchCommand,-2,CMD_NOSCRIPT|CMD_LOADING|CMD_STALE|CMD_FAST|CMD_ALLOW_BUSY,ACL_CATEGORY_TRANSACTION,WATCH_Keyspecs,1,NULL,1),.args=WATCH_Args}, diff --git a/src/commands/exec.json b/src/commands/exec.json index b39849fedf..5f03d76e08 100644 --- a/src/commands/exec.json +++ b/src/commands/exec.json @@ -10,8 +10,7 @@ "NOSCRIPT", "LOADING", "STALE", - "SKIP_SLOWLOG", - "SKIP_FATLOG" + "SKIP_SLOWLOG" ], "acl_categories": [ "TRANSACTION" diff --git a/src/commands/fatlog-get.json b/src/commands/fatlog-get.json index 181e79435c..16870a8be2 100644 --- a/src/commands/fatlog-get.json +++ b/src/commands/fatlog-get.json @@ -3,10 +3,10 @@ "summary": "Returns the fat log's entries.", "complexity": "O(N) where N is the number of entries returned", "group": "server", - "since": "7.2.5", + "since": "8.0.0", "arity": -2, "container": "FATLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "history": [], "command_flags": [ "ADMIN", diff --git a/src/commands/fatlog-help.json b/src/commands/fatlog-help.json index de739bd17d..b3dc00dfb0 100644 --- a/src/commands/fatlog-help.json +++ b/src/commands/fatlog-help.json @@ -3,10 +3,10 @@ "summary": "Show helpful text about the different subcommands", "complexity": "O(1)", "group": "server", - "since": "7.2.5", + "since": "8.0.0", "arity": 2, "container": "FATLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "command_flags": [ "LOADING", "STALE" diff --git a/src/commands/fatlog-len.json b/src/commands/fatlog-len.json index b3418dbb3b..32d477ddcd 100644 --- a/src/commands/fatlog-len.json +++ b/src/commands/fatlog-len.json @@ -3,10 +3,10 @@ "summary": "Returns the number of entries in the fat log.", "complexity": "O(1)", "group": "server", - "since": "7.2.5", + "since": "8.0.0", "arity": 2, "container": "FATLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "command_flags": [ "ADMIN", "LOADING", diff --git a/src/commands/fatlog-reset.json b/src/commands/fatlog-reset.json index ae9290aa97..38f401dbda 100644 --- a/src/commands/fatlog-reset.json +++ b/src/commands/fatlog-reset.json @@ -3,10 +3,10 @@ "summary": "Clears all entries from the fat log.", "complexity": "O(N) where N is the number of entries in the fatlog", "group": "server", - "since": "7.2.5", + "since": "8.0.0", "arity": 2, "container": "FATLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "command_flags": [ "ADMIN", "LOADING", diff --git a/src/commands/fatlog.json b/src/commands/fatlog.json index f5fe136fc6..954fbdca97 100644 --- a/src/commands/fatlog.json +++ b/src/commands/fatlog.json @@ -3,7 +3,7 @@ "summary": "A container for fat log commands.", "complexity": "Depends on subcommand.", "group": "server", - "since": "7.2.5", + "since": "8.0.0", "arity": -2 } } \ No newline at end of file diff --git a/src/commands/slowlog-get.json b/src/commands/slowlog-get.json index 5479f7e54b..ffc54b5454 100644 --- a/src/commands/slowlog-get.json +++ b/src/commands/slowlog-get.json @@ -6,7 +6,7 @@ "since": "2.2.12", "arity": -2, "container": "SLOWLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "history": [ [ "4.0.0", diff --git a/src/commands/slowlog-help.json b/src/commands/slowlog-help.json index 688f18ee30..dde8fd4598 100644 --- a/src/commands/slowlog-help.json +++ b/src/commands/slowlog-help.json @@ -6,7 +6,7 @@ "since": "6.2.0", "arity": 2, "container": "SLOWLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "command_flags": [ "LOADING", "STALE" diff --git a/src/commands/slowlog-len.json b/src/commands/slowlog-len.json index a5c53fea84..717a8ad416 100644 --- a/src/commands/slowlog-len.json +++ b/src/commands/slowlog-len.json @@ -6,7 +6,7 @@ "since": "2.2.12", "arity": 2, "container": "SLOWLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "command_flags": [ "ADMIN", "LOADING", diff --git a/src/commands/slowlog-reset.json b/src/commands/slowlog-reset.json index 32d5213229..cfc1e4da7f 100644 --- a/src/commands/slowlog-reset.json +++ b/src/commands/slowlog-reset.json @@ -6,7 +6,7 @@ "since": "2.2.12", "arity": 2, "container": "SLOWLOG", - "function": "heavyLoadLogCommand", + "function": "slowlogCommand", "command_flags": [ "ADMIN", "LOADING", diff --git a/src/config.c b/src/config.c index df04cb8fa5..c3b709129d 100644 --- a/src/config.c +++ b/src/config.c @@ -3166,8 +3166,8 @@ standardConfig static_configs[] = { createLongLongConfig("latency-monitor-threshold", NULL, MODIFIABLE_CONFIG, 0, LLONG_MAX, server.latency_monitor_threshold, 0, INTEGER_CONFIG, NULL, NULL), createLongLongConfig("proto-max-bulk-len", NULL, DEBUG_CONFIG | MODIFIABLE_CONFIG, 1024 * 1024, LONG_MAX, server.proto_max_bulk_len, 512ll * 1024 * 1024, MEMORY_CONFIG, NULL, NULL), /* Bulk request max size */ createLongLongConfig("stream-node-max-entries", NULL, MODIFIABLE_CONFIG, 0, LLONG_MAX, server.stream_node_max_entries, 100, INTEGER_CONFIG, NULL, NULL), - createLongLongConfig("repl-backlog-size", NULL, MODIFIABLE_CONFIG, 1, LLONG_MAX, server.repl_backlog_size, 1024*1024, MEMORY_CONFIG, NULL, updateReplBacklogSize), /* Default: 1mb */ - createLongLongConfig("fatlog-log-bigger-than", NULL, MODIFIABLE_CONFIG, -1, LLONG_MAX, server.fatlog_log_bigger_than, 16*1024, INTEGER_CONFIG, NULL, NULL), + createLongLongConfig("repl-backlog-size", NULL, MODIFIABLE_CONFIG, 1, LLONG_MAX, server.repl_backlog_size, 1024 * 1024, MEMORY_CONFIG, NULL, updateReplBacklogSize), /* Default: 1mb */ + createLongLongConfig("fatlog-log-bigger-than", NULL, MODIFIABLE_CONFIG, -1, LLONG_MAX, server.fatlog_log_bigger_than, 1024 * 1024, MEMORY_CONFIG, NULL, NULL), /* Unsigned Long Long configs */ createULongLongConfig("maxmemory", NULL, MODIFIABLE_CONFIG, 0, ULLONG_MAX, server.maxmemory, 0, MEMORY_CONFIG, NULL, updateMaxmemory), diff --git a/src/module.c b/src/module.c index 98b32428db..ebb3d0e6c6 100644 --- a/src/module.c +++ b/src/module.c @@ -53,7 +53,7 @@ #include "server.h" #include "cluster.h" -#include "heavyloadlog.h" +#include "slowlog.h" #include "rdb.h" #include "monotonic.h" #include "script.h" @@ -1151,7 +1151,6 @@ int64_t commandFlagsFromString(char *s) { else if (!strcasecmp(t,"allow-stale")) flags |= CMD_STALE; else if (!strcasecmp(t,"no-monitor")) flags |= CMD_SKIP_MONITOR; else if (!strcasecmp(t,"no-slowlog")) flags |= CMD_SKIP_SLOWLOG; - else if (!strcasecmp(t,"no-fatlog")) flags |= CMD_SKIP_FATLOG; else if (!strcasecmp(t,"fast")) flags |= CMD_FAST; else if (!strcasecmp(t,"no-auth")) flags |= CMD_NO_AUTH; else if (!strcasecmp(t,"may-replicate")) flags |= CMD_MAY_REPLICATE; diff --git a/src/server.c b/src/server.c index b7253f54ad..5e1cb9b817 100644 --- a/src/server.c +++ b/src/server.c @@ -30,7 +30,7 @@ #include "server.h" #include "monotonic.h" #include "cluster.h" -#include "heavyloadlog.h" +#include "slowlog.h" #include "bio.h" #include "latency.h" #include "mt19937-64.h" @@ -2707,7 +2707,7 @@ void initServer(void) { serverPanic("Functions initialization failed, check the server logs."); exit(1); } - heavyLoadLogInit(); + slowlogInit(); latencyMonitorInit(); initSharedQueryBuf(); @@ -3256,14 +3256,14 @@ void slowlogPushCurrentCommand(client *c, struct serverCommand *cmd, ustime_t du /* Log the last command a client executed into the fatlog. */ void fatlogPushCurrentCommand(client *c, struct serverCommand *cmd, size_t size) { - /* Some commands may contain sensitive data that should not be available in the slowlog. */ + /* Some commands may contain sensitive data that should not be available in the fatlog. */ if (cmd->flags & CMD_SKIP_SLOWLOG) return; /* If command argument vector was rewritten, use the original * arguments. */ robj **argv = c->original_argv ? c->original_argv : c->argv; int argc = c->original_argv ? c->original_argc : c->argc; - fatlogPushEntryIfNeeded(c,argv,argc,size); + fatlogPushEntryIfNeeded(c, argv, argc, size); } /* This function is called in order to update the total command histogram duration. diff --git a/src/server.h b/src/server.h index f4b38cfd49..403e3f5cef 100644 --- a/src/server.h +++ b/src/server.h @@ -2328,9 +2328,7 @@ typedef int serverGetKeysProc(struct serverCommand *cmd, robj **argv, int argc, * * CMD_SKIP_MONITOR: Do not automatically propagate the command on MONITOR. * - * CMD_SKIP_SLOWLOG: Do not automatically propagate the command to the slowlog. - * - * CMD_SKIP_FATLOG: Do not automatically propagate the command to the fatlog. + * CMD_SKIP_SLOWLOG: Do not automatically propagate the command to the slowlog and fatlog. * * CMD_ASKING: Perform an implicit ASKING for this command, so the * command will be accepted in cluster mode if the slot is marked @@ -3602,7 +3600,7 @@ void saveCommand(client *c); void bgsaveCommand(client *c); void bgrewriteaofCommand(client *c); void shutdownCommand(client *c); -void heavyLoadLogCommand(client *c); +void slowlogCommand(client *c); void moveCommand(client *c); void copyCommand(client *c); void renameCommand(client *c); diff --git a/src/heavyloadlog.c b/src/slowlog.c similarity index 78% rename from src/heavyloadlog.c rename to src/slowlog.c index 2f84132b62..fd17843b81 100644 --- a/src/heavyloadlog.c +++ b/src/slowlog.c @@ -8,7 +8,7 @@ * Similarly, fatlog remembers the latest N queries that has a response * larger than K bytes. * - * The size of the response to reach to be logged in the fat lof is set + * The size of the response to reach to be logged in the fat log is set * using the 'fatlog-log-bigger-than' config directive, that is also * readable and writable using the CONFIG SET/GET command. * @@ -50,11 +50,11 @@ /* Create a new slowlog entry. * Incrementing the ref count of all the objects retained is up to * this function. */ -heavyLoadLogEntry *heavyLoadLogCreateEntry(client *c, robj **argv, int argc, long long cost, long long id) { - heavyLoadLogEntry *se = zmalloc(sizeof(*se)); +slowlogEntry *slowlogCreateEntry(client *c, robj **argv, int argc, long long cost, long long id) { + slowlogEntry *se = zmalloc(sizeof(*se)); int j, slargc = argc; - if (slargc > HEAVYLOAD_LOG_ENTRY_MAX_ARGC) slargc = HEAVYLOAD_LOG_ENTRY_MAX_ARGC; + if (slargc > SLOWLOG_ENTRY_MAX_ARGC) slargc = SLOWLOG_ENTRY_MAX_ARGC; se->argc = slargc; se->argv = zmalloc(sizeof(robj *) * slargc); for (j = 0; j < slargc; j++) { @@ -98,8 +98,8 @@ heavyLoadLogEntry *heavyLoadLogCreateEntry(client *c, robj **argv, int argc, lon * function matches the one of the 'free' method of adlist.c. * * This function will take care to release all the retained object. */ -void heavyLoadLogFreeEntry(void *septr) { - heavyLoadLogEntry *se = septr; +void slowlogFreeEntry(void *septr) { + slowlogEntry *se = septr; int j; for (j = 0; j < se->argc; j++) decrRefCount(se->argv[j]); @@ -111,13 +111,13 @@ void heavyLoadLogFreeEntry(void *septr) { /* Initialize the slow log. This function should be called a single time * at server startup. */ -void heavyLoadLogInit(void) { +void slowlogInit(void) { server.slowlog = listCreate(); server.slowlog_entry_id = 0; - listSetFreeMethod(server.slowlog, heavyLoadLogFreeEntry); + listSetFreeMethod(server.slowlog, slowlogFreeEntry); server.fatlog = listCreate(); server.fatlog_entry_id = 0; - listSetFreeMethod(server.fatlog, heavyLoadLogFreeEntry); + listSetFreeMethod(server.fatlog, slowlogFreeEntry); } /* Push a new entry into the slow log. @@ -126,8 +126,7 @@ void heavyLoadLogInit(void) { void slowlogPushEntryIfNeeded(client *c, robj **argv, int argc, long long duration) { if (server.slowlog_log_slower_than < 0 || server.slowlog_max_len == 0) return; /* Slowlog disabled */ if (duration >= server.slowlog_log_slower_than) - listAddNodeHead(server.slowlog, - heavyLoadLogCreateEntry(c, argv, argc, duration, server.slowlog_entry_id++)); + listAddNodeHead(server.slowlog, slowlogCreateEntry(c, argv, argc, duration, server.slowlog_entry_id++)); /* Remove old entries if needed. */ while (listLength(server.slowlog) > server.slowlog_max_len) listDelNode(server.slowlog, listLast(server.slowlog)); @@ -137,24 +136,21 @@ void slowlogPushEntryIfNeeded(client *c, robj **argv, int argc, long long durati * This function will make sure to trim the fat log accordingly to the * configured max length. */ void fatlogPushEntryIfNeeded(client *c, robj **argv, int argc, long long cost) { - if (server.fatlog_log_bigger_than < 0 || server.fatlog_max_len == 0) return; /* Fatlog disabled */ + if (server.fatlog_max_len == 0) return; /* Fatlog disabled */ if (cost >= server.fatlog_log_bigger_than) - listAddNodeHead(server.fatlog, - heavyLoadLogCreateEntry(c, argv, argc, cost, server.fatlog_entry_id++)); + listAddNodeHead(server.fatlog, slowlogCreateEntry(c, argv, argc, cost, server.fatlog_entry_id++)); /* Remove old entries if needed. */ - while (listLength(server.fatlog) > server.fatlog_max_len) - listDelNode(server.fatlog,listLast(server.fatlog)); + while (listLength(server.fatlog) > server.fatlog_max_len) listDelNode(server.fatlog, listLast(server.fatlog)); } /* Remove all the entries from the current slow/fat log. */ -void heavyLoadLogReset(list *log_list) { - while (listLength(log_list) > 0) - listDelNode(log_list, listLast(log_list)); +void slowlogReset(list *log_list) { + while (listLength(log_list) > 0) listDelNode(log_list, listLast(log_list)); } /* The SLOWLOG/FATLOG command. Implements all the subcommands needed to handle the * slow/fat log. */ -void heavyLoadLogCommand(client *c) { +void slowlogCommand(client *c) { const char **help; list *log_list; const char *slowlog_help[] = { @@ -182,7 +178,7 @@ NULL NULL }; - if (!strcasecmp(c->argv[0]->ptr,"slowlog")){ + if (!strcasecmp(c->argv[0]->ptr, "slowlog")) { help = slowlog_help; log_list = server.slowlog; } else { @@ -190,20 +186,18 @@ NULL log_list = server.fatlog; } - if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) { + if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr, "help")) { addReplyHelp(c, help); - } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"reset")) { - heavyLoadLogReset(log_list); - addReply(c,shared.ok); - } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"len")) { - addReplyLongLong(c,listLength(log_list)); - } else if ((c->argc == 2 || c->argc == 3) && - !strcasecmp(c->argv[1]->ptr,"get")) - { + } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr, "reset")) { + slowlogReset(log_list); + addReply(c, shared.ok); + } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr, "len")) { + addReplyLongLong(c, listLength(log_list)); + } else if ((c->argc == 2 || c->argc == 3) && !strcasecmp(c->argv[1]->ptr, "get")) { long count = 10; listIter li; listNode *ln; - heavyLoadLogEntry *se; + slowlogEntry *se; if (c->argc == 3) { /* Consume count arg. */ @@ -228,15 +222,14 @@ NULL ln = listNext(&li); se = ln->value; - addReplyArrayLen(c,6); - addReplyLongLong(c,se->id); - addReplyLongLong(c,se->time); - addReplyLongLong(c,se->cost); - addReplyArrayLen(c,se->argc); - for (j = 0; j < se->argc; j++) - addReplyBulk(c,se->argv[j]); - addReplyBulkCBuffer(c,se->peerid,sdslen(se->peerid)); - addReplyBulkCBuffer(c,se->cname,sdslen(se->cname)); + addReplyArrayLen(c, 6); + addReplyLongLong(c, se->id); + addReplyLongLong(c, se->time); + addReplyLongLong(c, se->cost); + addReplyArrayLen(c, se->argc); + for (j = 0; j < se->argc; j++) addReplyBulk(c, se->argv[j]); + addReplyBulkCBuffer(c, se->peerid, sdslen(se->peerid)); + addReplyBulkCBuffer(c, se->cname, sdslen(se->cname)); } } else { addReplySubcommandSyntaxError(c); diff --git a/src/heavyloadlog.h b/src/slowlog.h similarity index 79% rename from src/heavyloadlog.h rename to src/slowlog.h index 39fed3320d..8dd803b177 100644 --- a/src/heavyloadlog.h +++ b/src/slowlog.h @@ -27,8 +27,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __HEAVY_LOAD_LOG_H__ -#define __HEAVY_LOAD_LOG_H__ +#ifndef __SLOWLOG_H__ +#define __SLOWLOG_H__ #include "server.h" @@ -36,19 +36,19 @@ #define SLOWLOG_ENTRY_MAX_STRING 128 /* This structure defines an entry inside the slow/fat log list */ -typedef struct heavyLoadLogEntry { +typedef struct slowlogEntry { robj **argv; int argc; - long long id; /* Unique entry identifier. */ - long long cost; /* Time spent by the query, in microseconds, or memory used by response packet, in bytes. */ - time_t time; /* Unix time at which the query was executed. */ - sds cname; /* Client name. */ - sds peerid; /* Client network address. */ -} heavyLoadLogEntry; + long long id; /* Unique entry identifier. */ + long long cost; /* Time spent by the query, in microseconds, or memory used by response packet, in bytes. */ + time_t time; /* Unix time at which the query was executed. */ + sds cname; /* Client name. */ + sds peerid; /* Client network address. */ +} slowlogEntry; /* Exported API */ -void heavyLoadLogInit(void); +void slowlogInit(void); void slowlogPushEntryIfNeeded(client *c, robj **argv, int argc, long long duration); void fatlogPushEntryIfNeeded(client *c, robj **argv, int argc, long long cost); -#endif /* __HEAVY_LOAD_LOG_H__ */ +#endif /* __SLOWLOG_H__ */ diff --git a/tests/unit/fatlog.tcl b/tests/unit/fatlog.tcl index 0c031fa278..50a83c986b 100644 --- a/tests/unit/fatlog.tcl +++ b/tests/unit/fatlog.tcl @@ -66,7 +66,6 @@ start_server {tags {"fatlog"}} { r acl getuser fatlog-test-user r acl deluser fatlog-test-user non-existing-user r config set fatlog-log-bigger-than 0 - r config set fatlog-log-bigger-than -1 set fatlog_resp [r fatlog get -1] # Make sure normal configs work, but the two sensitive @@ -91,7 +90,6 @@ start_server {tags {"fatlog"}} { r migrate [srv 0 host] [srv 0 port] key 9 5000 r migrate [srv 0 host] [srv 0 port] key 9 5000 AUTH user r migrate [srv 0 host] [srv 0 port] key 9 5000 AUTH2 user password - r config set fatlog-log-bigger-than -1 set fatlog_resp [r fatlog get] # Make sure all 3 commands were logged, but the sensitive fields are omitted @@ -192,7 +190,7 @@ start_server {tags {"fatlog"}} { r fatlog reset r get a assert_equal [r fatlog len] 1 - r config set fatlog-log-bigger-than -1 + r config set fatlog-max-len 0 r fatlog reset r get a assert_equal [r fatlog len] 0