Key hashing returns 0 and fails in cache.add
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Memcached |
New
|
Undecided
|
Unassigned |
Bug Description
I've somehow found a cache key that memcached cannot support in Python 2.7.5/Django 1.4.2 final.
In our application, we have an order transaction call that charges a customer's credit card. Before that part of the code runs, I cache a "True" value to memcached so that if it happens to run twice (double click, two people logged in at once, etc.) the second doesn't accidentally charge the call twice.
This is the call:
its = 0
while not cache.add(
time.sleep(2)
its += 1
if ts >= 60:
raise Exception('blah blah')
Now this works flawlessly except on my two WebFaction servers with THIS key:
"transaction_
If I use that, cache.add(
If I change ANY one character -- add one to the end, take one out, capitalize, lowercase, etc. -- just one character -- then it works.
Otherwise it appears be hashing to 0.
On my local machine, this doesn't happen -- it's only on my two (different) servers hosted by WebFaction. I have a feeling I've found some kind of anomalous key value that yields a 0-hash. Obviously since it's environment dependent I have a feeling some system values will be relevant to this (maybe they're used in hash computation?). Anyway, I have no idea what they would be, so please ask and I'll provide.
I did notice too that on my local system I am running Python 2.7.5+ (maybe a fix in that fixed the issue?)
Otherwise the two WebFaction systems are identical as far as I can tell -- CentOS 6.5 Final.