vendredi 19 septembre 2014

Prioritizing Transactions in Google AppEngine


Vote count:

0




Let's say I need to perform two different kinds write operations on a datastore entity that might happen simultaneously, for example:



  • The client that holds a write-lock on the entry updates the entry's content

  • The client requests a refresh of the write-lock (updates the lock's expiration time-stamp)


As the content-update operation is only allowed if the client holds the current write-lock, I need to perform the lock-check and the content-write in a transaction (unless there is another way that I am missing?). Also, a lock-refresh must happen in a transaction because the client needs to first be confirmed as the current lock-holder.


The lock-refresh is a very quick operation.


The content-update operation can be quite complex. Think of it as the client sending the server a complicated update-script that the server executes on the content.


Given this, if there is a conflict between those two transactions (should they be executed simultaneously), I would much rather have the lock-refresh operation fail (especially since the content-update performs an implicit lock-refresh anyways) than the complex content-update.


Is there a way that I can "prioritize" the content-update transaction? I don't see anything in the docs and I would imagine that this is not a specific feature, but maybe there is some trick I can use?


For example, what happens if my content-update reads the entry, writes it back with a small modification (without committing the transaction), then performs the lengthy operation and finally writes the result and commits the transaction? Would the first write be applied immediately and cause a simultaneous lock-refresh transaction to fail? Or are all writes kept until the transaction is committed at the end?


Is there such a thing as keeping two transactions open? Or doing an intermediate commit in a transaction?


Clearly, I can just split my content-update into two transactions: The first one sets a "don't mess with this, please!"-flag and the second one (later) writes the changes and clears that flag.


But maybe there is some other trick to achieve this with fewer reads/writes/transactions?



asked 41 secs ago

Markus A.

4,040






Prioritizing Transactions in Google AppEngine

Aucun commentaire:

Enregistrer un commentaire