config file and the server is using more than maxmemory bytes of memory.
In short this commands are denied on low memory conditions. */
#define REDIS_CMD_DENYOOM 4
+#define REDIS_CMD_FORCE_REPLICATION 8 /* Force replication even if dirty is 0 */
/* Object types */
#define REDIS_STRING 0
{"unsubscribe",unsubscribeCommand,-1,REDIS_CMD_INLINE,NULL,0,0,0},
{"psubscribe",psubscribeCommand,-2,REDIS_CMD_INLINE,NULL,0,0,0},
{"punsubscribe",punsubscribeCommand,-1,REDIS_CMD_INLINE,NULL,0,0,0},
- {"publish",publishCommand,3,REDIS_CMD_BULK,NULL,0,0,0},
+ {"publish",publishCommand,3,REDIS_CMD_BULK|REDIS_CMD_FORCE_REPLICATION,NULL,0,0,0},
{NULL,NULL,0,0,NULL,0,0,0}
};
redisLog(REDIS_WARNING, "Background saving error");
} else {
redisLog(REDIS_WARNING,
- "Background saving terminated by signal");
+ "Background saving terminated by signal %d", WTERMSIG(statloc));
rdbRemoveTempFile(server.bgsavechildpid);
}
server.bgsavechildpid = -1;
redisLog(REDIS_WARNING, "Background append only file rewriting error");
} else {
redisLog(REDIS_WARNING,
- "Background append only file rewriting terminated by signal");
+ "Background append only file rewriting terminated by signal %d",
+ WTERMSIG(statloc));
}
cleanup:
sdsfree(server.bgrewritebuf);
dirty = server.dirty;
cmd->proc(c);
- if (server.appendonly && server.dirty-dirty)
+ dirty = server.dirty-dirty;
+
+ if (server.appendonly && dirty)
feedAppendOnlyFile(cmd,c->db->id,c->argv,c->argc);
- if (server.dirty-dirty && listLength(server.slaves))
+ if ((dirty || cmd->flags & REDIS_CMD_FORCE_REPLICATION) &&
+ listLength(server.slaves))
replicationFeedSlaves(server.slaves,c->db->id,c->argv,c->argc);
if (listLength(server.monitors))
replicationFeedSlaves(server.monitors,c->db->id,c->argv,c->argc);
int level = 1;
while ((random()&0xFFFF) < (ZSKIPLIST_P * 0xFFFF))
level += 1;
- return level;
+ return (level<ZSKIPLIST_MAXLEVEL) ? level : ZSKIPLIST_MAXLEVEL;
}
static void zslInsert(zskiplist *zsl, double score, robj *obj) {
addReplyLong(c, dstzset->zsl->length);
server.dirty++;
} else {
- decrRefCount(dstzset);
+ decrRefCount(dstobj);
addReply(c, shared.czero);
}
zfree(src);
decrRefCount(valobj);
o->ptr = zm;
- /* And here there is the second check for hash conversion...
- * we want to do it only if the operation was not just an update as
- * zipmapLen() is O(N). */
- if (!update && zipmapLen(zm) > server.hash_max_zipmap_entries)
+ /* And here there is the second check for hash conversion. */
+ if (zipmapLen(zm) > server.hash_max_zipmap_entries)
convertToRealHash(o);
} else {
tryObjectEncoding(c->argv[2]);
}
static void hincrbyCommand(redisClient *c) {
- int update = 0;
long long value = 0, incr = 0;
robj *o = lookupKeyWrite(c->db,c->argv[1]);
value += incr;
sds svalue = sdscatprintf(sdsempty(),"%lld",value);
zm = zipmapSet(zm,c->argv[2]->ptr,sdslen(c->argv[2]->ptr),
- (unsigned char*)svalue,sdslen(svalue),&update);
+ (unsigned char*)svalue,sdslen(svalue),NULL);
sdsfree(svalue);
o->ptr = zm;
- /* Check if the zipmap needs to be converted
- * if this was not an update. */
- if (!update && zipmapLen(zm) > server.hash_max_zipmap_entries)
+ /* Check if the zipmap needs to be converted. */
+ if (zipmapLen(zm) > server.hash_max_zipmap_entries)
convertToRealHash(o);
} else {
robj *hval;