App Engine Datastore - consistency and 1 write per sec limitation - who will it work in the following scenarious

StackOverflow https://stackoverflow.com/questions/16375249

Pergunta

I'm trying to wrap my head around eventuality consistency and 1 write per sec principles in GAE datastore. I have a scenario and two questions:

#python like pseudo-code
class User:
   user_id = StringProperty
   last_update_time = DateTimeProperty

class Comment:    
   user_id = StringProperty
   comment = StringProperty

...
def AddCommentAndReturnAllComments(user_id):
    user = db.GqlQuery("SELECT * FROM User where user_id = :1", user_id)

    user.last_update_time = datetime.now()
    user.put()

    comment = Comment(parent=User(user_id))
    comment.put()

    comments = db.GqlQuery("SELECT * FROM Comment where user_id = :1", user_id)   
    return comments

Questions:

  1. Will I get an exception here because I make two writes into the same EntityGroup within one second (user.put and comment.put)? Is there a simple way around it?
  2. If I remove the parent=user(user_id), the two entities will no longer belong to the same EntityGroup. Does it mean that the list of comments returned from the function might not contain the last added comment?
  3. Am I doing something inherently wrong?

I know that I got the entity referencing part wrong. It doesn't matter for the question (or does it?)

Foi útil?

Solução

  1. This seems to be a soft limit. In practice I see up to 5 writes/s allowed.

  2. Yes and it also happens now, because you are not using ancestor query.

  3. Nothing, except as mentioned in point 2.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top