Key hashing returns 0 and fails in cache.add

Bug #1295222 reported by Nunya
6
This bug affects 1 person
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(cache_key, True, 60):
    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_93x9pzt_vendor_credit"

If I use that, cache.add("transaction_93x9pzt_vendor_credit", True, 60) always returns int(0) even though cache.get("transaction_93x9pzt_vendor_credit") returns NoneType.

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.