nerdexam
GoogleGoogle

PROFESSIONAL-CLOUD-DEVELOPER · Question #23

PROFESSIONAL-CLOUD-DEVELOPER Question #23: Real Exam Question with Answer & Explanation

The correct answer is B: Get and put the entity in a transaction.. https://cloud.google.com/datastore/docs/concepts/transactions#uses_for_transactions This requires a transaction because the value of balance in an entity may be updated by another user after this code fetches the object, but before it saves the modified object. Without a transact

Implementing Data Storage Solutions

Question

Your teammate has asked you to review the code below, which is adding a credit to an account balance in Cloud Datastore. Which improvement should you suggest your teammate make?

Options

  • AGet the entity with an ancestor query.
  • BGet and put the entity in a transaction.
  • CUse a strongly consistent transactional database.
  • DDon't return the account entity from the function.

Explanation

https://cloud.google.com/datastore/docs/concepts/transactions#uses_for_transactions This requires a transaction because the value of balance in an entity may be updated by another user after this code fetches the object, but before it saves the modified object. Without a transaction, the user's request uses the value of balance prior to the other user's update, and the save overwrites the new value. With a transaction, the application is told about the other user's

Topics

#Cloud Datastore#Transactions#Data Consistency#Concurrency Control

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER PracticeBrowse All PROFESSIONAL-CLOUD-DEVELOPER Questions