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
df3c69e8
Commit
df3c69e8
authored
Jul 01, 2016
by
antirez
Browse files
In Redis RDB check: log object type on error.
parent
c0f4d193
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-check-rdb.c
View file @
df3c69e8
...
...
@@ -40,6 +40,7 @@ int rdbCheckMode = 0;
struct
{
rio
*
rio
;
robj
*
key
;
/* Current key we are reading. */
int
key_type
;
/* Current key type if != -1. */
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. */
...
...
@@ -68,6 +69,23 @@ char *rdb_check_doing_string[] = {
"read-aux"
};
char
*
rdb_type_string
[]
=
{
"string"
,
"list-linked"
,
"set-hashtable"
,
"zset-v1"
,
"hash-hashtable"
,
"zset-v2"
,
"module-value"
,
""
,
""
,
"hash-zipmap"
,
"list-ziplist"
,
"set-intset"
,
"zset-ziplist"
,
"hash-ziplist"
,
"quicklist"
};
/* Show a few stats collected into 'rdbstate' */
void
rdbShowGenericInfo
(
void
)
{
printf
(
"[info] %lu keys read
\n
"
,
rdbstate
.
keys
);
...
...
@@ -94,6 +112,12 @@ void rdbCheckError(const char *fmt, ...) {
if
(
rdbstate
.
key
)
printf
(
"[additional info] Reading key '%s'
\n
"
,
(
char
*
)
rdbstate
.
key
->
ptr
);
if
(
rdbstate
.
key_type
!=
-
1
)
printf
(
"[additional info] Reading type %d (%s)
\n
"
,
rdbstate
.
key_type
,
((
unsigned
)
rdbstate
.
key_type
<
sizeof
(
rdb_type_string
)
/
sizeof
(
char
*
))
?
rdb_type_string
[
rdbstate
.
key_type
]
:
"unknown"
);
rdbShowGenericInfo
();
}
...
...
@@ -128,8 +152,7 @@ void rdbCheckSetupSignals(void) {
sigemptyset
(
&
act
.
sa_mask
);
act
.
sa_flags
=
SA_NODEFER
|
SA_RESETHAND
|
SA_SIGINFO
;
#warning "Uncomment here"
// act.sa_sigaction = rdbCheckHandleCrash;
act
.
sa_sigaction
=
rdbCheckHandleCrash
;
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
sigaction
(
SIGBUS
,
&
act
,
NULL
);
sigaction
(
SIGFPE
,
&
act
,
NULL
);
...
...
@@ -233,6 +256,7 @@ int redis_check_rdb(char *rdbfilename) {
rdbCheckError
(
"Invalid object type: %d"
,
type
);
return
1
;
}
rdbstate
.
key_type
=
type
;
}
/* Read key */
...
...
@@ -254,6 +278,7 @@ int redis_check_rdb(char *rdbfilename) {
rdbstate
.
key
=
NULL
;
decrRefCount
(
key
);
decrRefCount
(
val
);
rdbstate
.
key_type
=
-
1
;
}
/* Verify the checksum if RDB version is >= 5 */
if
(
rdbver
>=
5
&&
server
.
rdb_checksum
)
{
...
...
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