Upon deeper consideration, whether or not Monotonic currently could
produce dups depends on the exact behavior of:

MemcacheService.increment(java.lang.Object key, long delta,
java.lang.Long initialValue)

Unfortunately the documentation is ambiguous about what the return
value will be when MemcacheService is down.  Does it return null or
does it return initialValue?

If it returns null like the non-initial-value version (which is what
the code currently assumes), the current Monotonic code is safe and
won't produce duplicates.  It will throw an IllegalStateException.

If this method returns initialValue, it's still pretty easy to change
the logic to guarantee IllegalStateException instead.

Goog, any clarification of what MemcacheService.increment() does?

Jeff

On Sun, Jan 2, 2011 at 6:27 AM, Jeff Schwartz <[email protected]> wrote:
> It is safe. The montonic implementation expressly handled those cases where
> memcache is not available and throws an IllegalStateException. When memcache
> is not available you can be almost certain that the datastore isn't
> available as well so responding to these cases appropriately - such as
> redirecting a user to a page explaining that the datastore isn't currently
> available - will ensure that you maintain the integrity of the data.
>
> Jeff Schwartz
>
>
>
>
> On Sun, Jan 2, 2011 at 12:56 AM, aswath satrasala
> <[email protected]> wrote:
>>
>> Hi MG,
>> I am currently using the following in my application.
>>
>> http://blog.appenginefan.com/2009/04/efficient-global-counters-revisited.html.
>> It does not use Objectify
>>
>> But, I was planning to use the Objecify Monotic, so as to keep counter
>> implementation simple and not worry about another library details.  Now,
>> with your valid points, it is good discussion thread with Objectify team and
>> find out what they think.
>>
>> -Aswath
>> www.AccountingGuru.in
>>
>> On Sat, Jan 1, 2011 at 10:13 PM, MG <[email protected]> wrote:
>>>
>>> Monotonic in Objectify, as defined here:
>>>
>>>
>>> http://code.google.com/p/objectify-appengine/source/browse/trunk/src/com/googlecode/objectify/helper/Monotonic.java?r=620
>>>
>>> is not 100% safe. For example:
>>>
>>> 1. Memcache is off, lastMax is 100
>>> 2. Memcache goes up for 1 sec, five requests get 101, 102, ... 105
>>> numbers for them
>>> 3. Memcache goes off again for 1 sec; requests from #2 are still
>>> preparing data to insert in the related datastore model
>>> 4. Memcache goes up, another five requests get 101, 102, ..., 105 numbers
>>> for them
>>> 5. now we have duplicate numbers.
>>>
>>> MG
>>>
>>> On Saturday, January 1, 2011 11:08:50 AM UTC-5, aswath wrote:
>>>>
>>>> I was seeing your link.  You have used Objectify.  Objectify already
>>>> provides Monotonic helper class.
>>>>
>>>> -Aswath
>>>> www.accountingguru.in
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>
>
> --
> Jeff Schwartz
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to