]> git.saurik.com Git - redis.git/blobdiff - src/debug.c
Don't change the replication state if SLAVE OF is called with arguments specifying...
[redis.git] / src / debug.c
index d610d2a97d4fe96d677d1d7edcff3a12c422b492..728aa8a18cc052277f8520759d4cb916e845267e 100644 (file)
@@ -216,12 +216,12 @@ void debugCommand(redisClient *c) {
         if (c->argc >= 3) c->argv[2] = tryObjectEncoding(c->argv[2]);
         redisAssertWithInfo(c,c->argv[0],1 == 2);
     } else if (!strcasecmp(c->argv[1]->ptr,"reload")) {
-        if (rdbSave(server.dbfilename) != REDIS_OK) {
+        if (rdbSave(server.rdb_filename) != REDIS_OK) {
             addReply(c,shared.err);
             return;
         }
         emptyDb();
-        if (rdbLoad(server.dbfilename) != REDIS_OK) {
+        if (rdbLoad(server.rdb_filename) != REDIS_OK) {
             addReplyError(c,"Error trying to load the RDB dump");
             return;
         }
@@ -229,10 +229,11 @@ void debugCommand(redisClient *c) {
         addReply(c,shared.ok);
     } else if (!strcasecmp(c->argv[1]->ptr,"loadaof")) {
         emptyDb();
-        if (loadAppendOnlyFile(server.appendfilename) != REDIS_OK) {
+        if (loadAppendOnlyFile(server.aof_filename) != REDIS_OK) {
             addReply(c,shared.err);
             return;
         }
+        server.dirty = 0; /* Prevent AOF / replication */
         redisLog(REDIS_WARNING,"Append Only File loaded by DEBUG LOADAOF");
         addReply(c,shared.ok);
     } else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) {
@@ -335,9 +336,7 @@ void _redisAssertPrintClientInfo(redisClient *c) {
     }
 }
 
-void _redisAssertPrintObject(robj *o) {
-    bugReportStart();
-    redisLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ===");
+void redisLogObjectDebugInfo(robj *o) {
     redisLog(REDIS_WARNING,"Object type: %d", o->type);
     redisLog(REDIS_WARNING,"Object encoding: %d", o->encoding);
     redisLog(REDIS_WARNING,"Object refcount: %d", o->refcount);
@@ -345,9 +344,25 @@ void _redisAssertPrintObject(robj *o) {
         redisLog(REDIS_WARNING,"Object raw string len: %d", sdslen(o->ptr));
         if (sdslen(o->ptr) < 4096)
             redisLog(REDIS_WARNING,"Object raw string content: \"%s\"", (char*)o->ptr);
+    } else if (o->type == REDIS_LIST) {
+        redisLog(REDIS_WARNING,"List length: %d", (int) listTypeLength(o));
+    } else if (o->type == REDIS_SET) {
+        redisLog(REDIS_WARNING,"Set size: %d", (int) setTypeSize(o));
+    } else if (o->type == REDIS_HASH) {
+        redisLog(REDIS_WARNING,"Hash size: %d", (int) hashTypeLength(o));
+    } else if (o->type == REDIS_ZSET) {
+        redisLog(REDIS_WARNING,"Sorted set size: %d", (int) zsetLength(o));
+        if (o->encoding == REDIS_ENCODING_SKIPLIST)
+            redisLog(REDIS_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level);
     }
 }
 
+void _redisAssertPrintObject(robj *o) {
+    bugReportStart();
+    redisLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ===");
+    redisLogObjectDebugInfo(o);
+}
+
 void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int line) {
     if (c) _redisAssertPrintClientInfo(c);
     if (o) _redisAssertPrintObject(o);