Skip to content

Commit 524a765

Browse files
netinetwalkerest31
authored andcommittedSep 26, 2015
redis: throw error if block request failed
Fixes #3196. Before, we didn't throw an error, and the engine thought the block isn't occupied. But in fact it might be that redis is still loading, and the block does exist in the database. The result was a cheesy map.
1 parent f062bbd commit 524a765

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed
 

‎src/database-redis.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,21 @@ std::string Database_Redis::loadBlock(const v3s16 &pos)
118118
freeReplyObject(reply);
119119
return str;
120120
}
121-
case REDIS_REPLY_ERROR:
122-
errorstream << "WARNING: loadBlock: loading block " << PP(pos)
123-
<< " failed: " << reply->str << std::endl;
121+
case REDIS_REPLY_ERROR: {
122+
std::string errstr = reply->str;
123+
freeReplyObject(reply);
124+
errorstream << "loadBlock: loading block " << PP(pos)
125+
<< " failed: " << errstr << std::endl;
126+
throw FileNotGoodException(std::string(
127+
"Redis command 'HGET %s %s' errored: ") + errstr);
128+
}
124129
}
130+
errorstream << "loadBlock: loading block " << PP(pos)
131+
<< " returned invalid reply type " << reply->type
132+
<< ": " << reply->str << std::endl;
125133
freeReplyObject(reply);
126-
return "";
134+
throw FileNotGoodException(std::string(
135+
"Redis command 'HGET %s %s' gave invalid reply."));
127136
}
128137

129138
bool Database_Redis::deleteBlock(const v3s16 &pos)

0 commit comments

Comments
 (0)
Please sign in to comment.