Skip to content
This repository has been archived by the owner on Aug 18, 2019. It is now read-only.

Increments in an existing Transaction may populate Memcache incorrectly #17

Closed
sappenin opened this issue Jan 20, 2015 · 0 comments
Closed
Labels

Comments

@sappenin
Copy link
Member

Steps to recreate:

  • Start a Datastore TX.
  • Increment a counter that is not currently in memcache, setting "isolated" to false so that the increment occurs as part of the current TX.
  • ShardedCounterServiceImpl#increment will end with a call to #getCounter, which will query the datastore for Shard values in an attempt to get the counter's count. Since the initial TX is still open, no shards will be returned (any loads from the Datastore will reflect the current state of the datastore as of the beginning of the TX).
  • Memcache will be initialized to 0, which is should really be 1 or some other value that's truly the count. Or, if the counter has "count", but hasn't been accessed in a while, then an old value of the count may be populated into memcache.

This problem will go away after the cache entry is evicted, but can cause an incorrect counter count for a short period of time.

Possible Fixes:

  1. Remove the return value of all increment methods so the cache is not updated until all TX's have concluded.
@sappenin sappenin added the bug label Jan 20, 2015
sappenin added a commit that referenced this issue Feb 10, 2015
+ Fixes #11 Default Delete Implementation
+ Fixes #16 Remove redundant counterShard datastore put in ShardedCounterServiceImpl#increment
+ Fixes #17 Enhance the interface of CounterService to not return a count when incrementing/decrementing.
+ Fixes #7 numRetries doesn't get decremented in ShardedCounterServiceImpl.incrementMemcacheAtomic
+ Improve unit tests for new functionality.
sappenin added a commit that referenced this issue Feb 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant