slowlog get command supports passing in -1 to get all logs.#9018
Conversation
|
Also i think this comment about /* This structure defines an entry inside the slow log list */
typedef struct slowlogEntry {
robj **argv;
int argc;
long long id; /* Unique entry identifier. */
long long duration; /* Time spent by the query, in microseconds. */
time_t time; /* Unix time at which the query was executed. */
sds cname; /* Client name. */
sds peerid; /* Client network address. */
} slowlogEntry;In slowlogEntry *slowlogCreateEntry(client *c, robj **argv, int argc, long long duration) {
....
se->time = time(NULL); // here
se->duration = duration;
se->id = server.slowlog_entry_id++;
se->peerid = sdsnew(getClientPeerId(c));
se->cname = c->name ? sdsnew(c->name->ptr) : sdsempty();
return se;
} |
|
@enjoy-binbin The record time of slowlogCreateEntry is actually very close to the time when the command is run. |
|
Yes i agree with that. Just for the record. Btw, if the command duration is long. Like is a really slow command. |
|
Read doc: https://redis.io/commands/slowlog. |
|
it looks like a bug, but maybe it can be considered a feature. regarding the comment or doc, from the perspective of the execution time record, IMHO it doesn't really matter if it's the beginning of the command or it's end. the typical use case is to see that some command took 20ms, and that it happened around 8am, i.e. see if it happened today, or yesterday, or match it to some maintainable operation, or a configuration change etc. |
|
Right. Sounds like a good idea. I like it. And for the comment or doc, i just thought about it when I saw it. Not need to fix it |
|
I agree, it really looks like a bug :). I would vote to make -1 a special value that means fetch the entire slowlog, and then make that clearer in the code. |
|
I agree with @madolson. |
e528049 to
a463a88
Compare
a463a88 to
65b22ad
Compare
65b22ad to
358dce4
Compare
madolson
left a comment
There was a problem hiding this comment.
Looks good to me, can you also submit a request here: https://github.com/redis/redis-doc for updating the documentation.
oranagra
left a comment
There was a problem hiding this comment.
thanks @enjoy-binbin .
can you please also make a PR to https://github.com/redis/redis-doc/pulls to document this.
Co-authored-by: Oran Agra <oran@redislabs.com>
|
@oranagra No problem. Doc pr: redis/redis-doc#1585 I alerady made but seems to forget metion in here |
|
@redis/core-team, we already have a majority, and this is in fact not a behavior change, but please respond if you feel documenting this behavior is wrong. |
|
@oranagra @madolson This idea came about suddenly. What do you think we add a lazyfree about the /* Remove all the entries from the current slow log. */
void slowlogReset(void) {
while (listLength(server.slowlog) > 0)
listDelNode(server.slowlog,listLast(server.slowlog));
}Sound silly, forget about that... No one would do it like me |
|
@enjoy-binbin Lol, lazyfree all of the things. Given that the default is 128, it's an anti-pattern to let it grown, I'm going to agree and say let's not make it lazyfree. |
This was already the case before this commit, but it wasn't clear / intended in the code, now it does.
New:
Based on the results of the comments, this commit introduced
slowlog get -1to get all slow logs.@oranagra Take a look for me when you have time. Check the code style and the help txt. Make sure i do it right. Thanks!
Need to be updated on the redis-doc?
--------- old comment ----------
Before: (When typing a negative count, it will traverse the whole slowlog list. When the slowlog list is huge. May cause serious consequences if the user type a wrong count.)
After: (So i added a check. I could not help myself...)