Commit 2a9c77a2 authored by Vitaly Arbuzov's avatar Vitaly Arbuzov
Browse files

Aof write SELECT outside of dict loop

parent 2ed31392
...@@ -2237,6 +2237,9 @@ int rewriteAppendOnlyFileRio(rio *aof) { ...@@ -2237,6 +2237,9 @@ int rewriteAppendOnlyFileRio(rio *aof) {
for (j = 0; j < server.dbnum; j++) { for (j = 0; j < server.dbnum; j++) {
char selectcmd[] = "*2\r\n$6\r\nSELECT\r\n"; char selectcmd[] = "*2\r\n$6\r\nSELECT\r\n";
/* SELECT the new DB */
if (rioWrite(aof, selectcmd, sizeof(selectcmd) - 1) == 0) goto werr;
if (rioWriteBulkLongLong(aof, j) == 0) goto werr;
redisDb *db = server.db + j; redisDb *db = server.db + j;
dict *d; dict *d;
dbIterator dbit; dbIterator dbit;
...@@ -2244,11 +2247,6 @@ int rewriteAppendOnlyFileRio(rio *aof) { ...@@ -2244,11 +2247,6 @@ int rewriteAppendOnlyFileRio(rio *aof) {
while ((d = dbNextDict(&dbit))) { while ((d = dbNextDict(&dbit))) {
if (dictSize(d) == 0) continue; if (dictSize(d) == 0) continue;
di = dictGetSafeIterator(d); di = dictGetSafeIterator(d);
/* SELECT the new DB */
if (rioWrite(aof, selectcmd, sizeof(selectcmd) - 1) == 0) goto werr;
if (rioWriteBulkLongLong(aof, j) == 0) goto werr;
/* Iterate this DB writing every entry */ /* Iterate this DB writing every entry */
while ((de = dictNext(di)) != NULL) { while ((de = dictNext(di)) != NULL) {
sds keystr; sds keystr;
......
...@@ -448,7 +448,7 @@ static int scriptVerifyClusterState(scriptRunCtx *run_ctx, client *c, client *or ...@@ -448,7 +448,7 @@ static int scriptVerifyClusterState(scriptRunCtx *run_ctx, client *c, client *or
* that weren't pre-declared. */ * that weren't pre-declared. */
if (hashslot != -1) { if (hashslot != -1) {
if (run_ctx->flags & SCRIPT_ALLOW_CROSS_SLOT) { if (run_ctx->flags & SCRIPT_ALLOW_CROSS_SLOT) {
original_c->db->command_slot = -1; /* Clear command slot for multislot scripts because script may access keys from differen slots. */ original_c->db->command_slot = -1; /* Clear command slot for multislot scripts because script may access keys from different slots. */
} else { } else {
if (original_c->slot == -1) { if (original_c->slot == -1) {
original_c->slot = hashslot; original_c->slot = hashslot;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment