zrange,zrevrange for large values returns variable number of nulls
Using the zrange or zrevrange on sorted sets with large values is causing unpredictable, inconsistent results with the new javascript parser. The resulting array is the expected length, however there are a variable number of null values. This changes from query to query on the same set. When values are small, the results are consistently correct. Additionally, the old hiredis parser worked consistently correctly with both large and small values.
Test script:
var redis = require('redis').createClient(),
util = require('util');
var key = 'ss_test';
var value = { 'foo' : 'bar' };
for( var i = 0; i < 400; i++ ){
value.foo += 'padding';
}
var values = [key];
for( var i = 0; i < 10; i++ ){
(function(i, value){ value.num = i; values.push(i, JSON.stringify(value))})(i, value);
}
redis.del( key, function( err, results ){
console.log( 'Delete Returned:', util.inspect(arguments) );
redis.zadd( values, function( err, results ){
console.log( 'Zadd Returned:', util.inspect(arguments) );
redis.zrange( key, 0, 10, function( err, results ){
console.log( 'Zrange Returned:', util.inspect(arguments) );
var good = 0,
bad = 0;
for( var i = 0, len = results.length; i < len; i++ ){
if(results[i]) good++;
else bad++;
}
console.log('Total:',len,'- Valid:',good,'- Null:',bad);
process.exit();
});
});
});
The values are all correctly being stored, confirmed both with redis-cli and using the hiredis parser.
System Details: Node v0.8.2 Redis v2.4.7, 64 bit node_redis v2.11.1, parser: native javascript
I can second this, getting a lot of null entries when zrevrangebyscore WITHSCORES on a large set. So when redis-cli returns 100 entries the driver sometimes returns x valid entries and y null entries in the array. Both the data and score fields are null on the invalid entries. The null entries are always at the end of the result set.
confirmed with node v0.8.9, redis v2.4.17 and node_redis v0.8.1.
Saw this too late, i opened another issue (#274) with the analysis of the problem.
the interesting thing with this is that i can only replicate this with redis 2.4.x. using redis 2.6.0rc6 (2.5.12) everything comes back as expected.
thanks for the test case, i am looking into it now, as it should work on all supported versions of redis.
gah, need to change my local username - but the diff pointed to should make a difference, can you please check it out and see if that has any ill affects?
Ranges are returning correctly, without nulls, using e61ff70 for me. Size no longer effects the outcome.
Closing as it sounds like this was fixed? Please reopen if this is not the case. Thanks, D