Environments: Ubuntu 10.04 64bit, Python Redis client 2.4.1, Redis 2.4.8, Python 2.6.5
Problem description:
I have some big Python dictionaries (key1:value1, key2:value2, ...). Each key is a short string, and each value is a simplejson dumped long string. I'd like to store dictionaries into different redis databases, I used the following code: "r.mset(the_dictionary)". It works for one dictionary, however, for another one, it prompts with "connection reset by peer" error. I am pretty sure the dictionaries are of the same format. I felt it strange to have such a fatal error.
Additionally, I have tried the following steps to identify the problem source:
- I separately insert each dictionary into Redis from flushed database (one new service for each dictionary). I still got the first dictionary insertion worked and the second failed.
- I suspect the problem is from the internal of second dictionary, so I tried to do some variable type and string length checks, all keys and values passed the simple check. But I still have the storage of second dictionary failed.
- If I change the dictionary values to the same constant variable (e.g. all values are set to "abc"), then the storage works.
- If I use r.hmset for each key and value in the second pairs, it works as well.
But why "r.mset(the_dictionry)" can work for one dictionary, but fail in another?
There must be something wrong in the values of dictionary or some bugs in the Python client.
I don't know how can I proceed to identify the problem source. Please give me some suggestions.
I searched google and tried redis server log, but still cannot get it through.
======Response to feedback====== Here is the code snippet:
db3 = redis.Redis(db=2)
db3.flushdb()
db3.mset(oov_dist_dict)
But if I follow feedback to split the dictionary and insert to redis, It works, Could you please explain it a little bit? I didn't see any statements in the official documents.