Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print the number of lua scripts if any when doing check-rdb #1448

Open
wants to merge 2 commits into
base: unstable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/valkey-check-rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct {
unsigned long keys; /* Number of keys processed. */
unsigned long expires; /* Number of keys with an expire. */
unsigned long already_expired; /* Number of keys already expired. */
unsigned long lua_scripts; /* Number of lua scripts. */
int doing; /* The state while reading the RDB. */
int error_set; /* True if error is populated. */
char error[1024];
Expand Down Expand Up @@ -108,6 +109,9 @@ void rdbShowGenericInfo(void) {
printf("[info] %lu keys read\n", rdbstate.keys);
printf("[info] %lu expires\n", rdbstate.expires);
printf("[info] %lu already expired\n", rdbstate.already_expired);
if (rdbstate.lua_scripts) {
printf("[info] %lu lua scripts read\n", rdbstate.lua_scripts);
}
}

/* Called on RDB errors. Provides details about the RDB and the offset
Expand Down Expand Up @@ -280,6 +284,13 @@ int redis_check_rdb(char *rdbfilename, FILE *fp) {
goto eoferr;
}

if (!strcasecmp(auxkey->ptr, "lua")) {
/* In older version before 7.0, we may save lua scripts in a replication RDB,
* although it is not an actually aux field, we will still print it in here since
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean "it is not an actually aux field"? It is an aux field.

Aux field doens't mean it's not used for anything. I just means that a server ignores it if it doesn't understands it.

Btw, isn't it equally easy to count the lua scripts using grep --count?

Copy link
Member Author

@enjoy-binbin enjoy-binbin Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I just wanted to say that it's not really aux, i.e. it's different from the other aux fields (unlike other aux that provide useful info like metadata, lua is considered a data here (client data or other)). But i can see the wording is ugly indeed.

I am just bother that we are talking about external grep here a lot, it should be friendly and easy to read on its own without external help. Do you want me to drop it?

* it's easy to filter using external grep. Use a counter so that at the end we
* can print its number, if any. */
rdbstate.lua_scripts++;
}
rdbCheckInfo("AUX FIELD %s = '%s'", (char *)auxkey->ptr, (char *)auxval->ptr);
decrRefCount(auxkey);
decrRefCount(auxval);
Expand Down
Loading