Closed rc-davis closed 10 years ago
It looks like new sketches are assigned a sketchId when they are uploaded, and this is found by incrementing the "sketch_count" field of the AppVersionCount singleton table in the DataStore. Is that right?
If so, then I suspect that this is a race condition on sketch_count. Remember that we are using the High Replication Data Store. That means there could be several copies of our database on different servers, and these are only guaranteed to be EVENTUALLY consistent. Thus, if we are uploading two sketches (A and B) at the same time, and we have two copies of the data store (X and Y), we could have the following situation:
1) Upload sketch A.
If I have diagnosed this correctly, then I can think of two ways to fix this:
Option 1: When fetching sketch_count, perform an ancestor query for a single entity group, as explained here: https://developers.google.com/appengine/docs/python/datastore/structuring_for_strong_consistency. This is probably the easiest way to fix this problem, but it should slow down uploads to one sketch per second.
Option 2: We could try using the "id" field wherever we currently use the "sketchId" field. This is created automatically and is always unique. The only problem is that the id field is probably larger than the sketchID field. This is hard to do, but it would probably work better in the long run.
Issue fixed using Option 2
I don't know how to reproduce this, but here's how to see the symptoms: