Stackexchange.redis: ERR Protocol error: invalid multibulk length

Created on 4 May 2015  Â·  14Comments  Â·  Source: StackExchange/StackExchange.Redis

Hi, mgravell. I got this error when I use the multi set keys to insert about 1 million records to redis at one time, i.e. the API in the StackExchange.Redis

bool StringSet(KeyValuePair<RedisKey, RedisValue>[] values, When when = When.Always, CommandFlags flags = CommandFlags.None);

and I searched the redis source code for ERR Protocol error: invalid multibulk length, but I'm sure my each value size is not bigger than 512MB, I can't figure out why, could you give me your help?

StackExchange.Redis.RedisServerException: ERR Protocol error: invalid multibulk length
   at StackExchange.Redis.ConnectionMultiplexer.ExecuteSyncImpl[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
   at StackExchange.Redis.RedisBase.ExecuteSync[T](Message message, ResultProcessor`1 processor, ServerEndPoint server)
enhancement

Most helpful comment

finally, I figured it out.
the length of args of the API command MSET can't be bigger than 1024 * 1024, so the length of the array KeyValuePair<RedisKey, RedisValue>[] values cant be bigger than 524288, so I limit it to 524287, then it works.
I hope this would be helpful others.

All 14 comments

finally, I figured it out.
the length of args of the API command MSET can't be bigger than 1024 * 1024, so the length of the array KeyValuePair<RedisKey, RedisValue>[] values cant be bigger than 524288, so I limit it to 524287, then it works.
I hope this would be helpful others.

Wow; I wonder if that is documented anywhere. Good find! Please could you
reopen? I would like to change the code to work more appropriately: either
throw before sending, or split the work into multiple commands.
On 4 May 2015 9:48 am, "Daniel Zhang" [email protected] wrote:

finally, I figured it out.
the length of args of the API command MSET can't be bigger than 1024 *
1024, so the length of the array KeyValuePair[]
values cant be bigger than 524288, so I limit it to 524287, then it works.
I hope this would be helpful others.

—
Reply to this email directly or view it on GitHub
https://github.com/StackExchange/StackExchange.Redis/issues/201#issuecomment-98639005
.

with pleasure ;)

Hi @mgravell, I searched this error message at: https://github.com/antirez/redis/blob/6c60526db91e23fb2d666fc52facc9a11780a2a3/src/networking.c#L1024
I think this should be the limitation of the MSET args length, though there is no document about this.

i still got this exception today. is this fixed ?

@631320085 not yet

Sorry for last comment, i was got this exception from ServiceStack.Redis yesterday. But today i use StackExchange.Redis SetAdd 1million values got a timeout exception, then i changed option's ConnectTimeout and SyncTimeout , it's worked. well done. @zhdaniel

+1

+1

+1

Do we have a date for when this is going to be fixed? I ran into this error today when we loaded data....

k, I'll take responsibility for this and get it fixed next deploy. sorry -
it slipped through the cracks because it got closed

On 10 Jul 2017 9:58 p.m., "aspnerd" notifications@github.com wrote:

When is this going to be fixed? I hit this error today once we loaded our
data. Not good.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/StackExchange/StackExchange.Redis/issues/201#issuecomment-314239596,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABDsFRjAGP-2Mf4vLxkTXLUMS1jNfcRks5sMpCNgaJpZM4EPAmj
.

very glad to hear that.

it's in Redis source code

/* We know for sure there is a whole line since newline != NULL,
* so go ahead and find out the multi bulk length. /
redisAssertWithInfo(c,NULL,c->querybuf[0] == '
');
ok = string2ll(c->querybuf+1,newline-(c->querybuf+1),&ll);
if (!ok || ll > 1024*1024) {
addReplyError(c,"Protocol error: invalid multibulk length");
setProtocolError(c,pos);
return REDIS_ERR;
}

Was this page helpful?
0 / 5 - 0 ratings