Grade 10 · lesson 3 of 4

Treat an All-or-Nothing Change as a Transaction

Commit the complete valid change or roll back the incomplete change.

About 22 minutes, plus any extended practice

Download the grade pack

Supplied materials

  • Paper and pencil; answers may also be spoken or typed.
  • All cases, labels, numbers and rules are supplied on this page. No real account, private information or purchase is needed.

Learn the idea

A transaction groups operations so the defined change can commit together or be rolled back. In our atomic transfer model, debiting A without crediting B is unacceptable. Transaction boundaries and error handling preserve the stated invariant. No real financial transfer occurs in this lesson.

Commit the complete valid change or roll back the incomplete change. Two successful-looking partial steps are not enough if their combined invariant is broken.

Use this supplied case: A loses 3 and B gains 3 with no error. Atomic model moves 3 tokens from A to B. Classify the recorded outcome. The task is to connect the given information to the computing idea. Write a short evidence trail so another learner can reproduce your choice. The simplified case describes the stated model, not every real system.

  1. Represent the supplied worked case with a labeled drawing, table or short trace.
  2. Commit the complete valid change or roll back the incomplete change.
  3. Explain why the worked answer fits and why one alternative does not.
  4. Try the new check and practice cases; revisit the stated rule if your evidence does not match.
Worked example

See the method in action

A fresh paper model has A=12 tokens and B=5. Moving 2 requires A=10 and B=7; the total stays 17. If the debit happens but credit fails, leaving A=10 and B=5 would lose 2 tokens from the combined record. Under the atomic policy, roll back to A=12 and B=5. Only a complete valid transfer commits. No actual money or learner record is changed in this model.

Your turn

Check your reasoning

Your answer is temporary and is not saved to an account. Download your current answer before leaving or reloading. Written work on paper or in another app stays in your own file.

Helpful tips
  • Commit the complete valid change or roll back the incomplete change.
  • Two successful-looking partial steps are not enough if their combined invariant is broken.
A loses 3 butB update fails. Atomic model moves 3 tokens from A to B. Classify the recorded outcome.

Feedback appears here after you check. This is practice, not a graded school assessment.

See the answer and explanation

Roll back incomplete transfer

Suppose account A has 10 tokens and B has 4. Moving 3 requires A=7 and B=7; the combined total remains 14. If the debit happens but the credit fails, keeping A=7 and B=4 loses 3 tokens and violates the complete-transfer requirement. Under the supplied atomic policy, roll back to A=10 and B=4. Only a complete valid operation commits. This paper model does not move actual money. The requested case is: A loses 3 butB update fails. Atomic model moves 3 tokens from A to B. Classify the recorded outcome. Its answer is Roll back incomplete transfer.

Take it further

New state: A=10 tokens and B=4. An atomic transfer of 2 requires A=8, B=6, combined total 14. If the credit fails, the stated rollback policy restores A=10 and B=4. Explain why a partial debit is unacceptable.

Nothing here is saved to an account or sent to a teacher. The answer download includes your current choice and any checked feedback. It does not include choices from the separate More practice section. Download that section separately.

More practice: try new cases

Choose an answer for each problem. Explain your method on paper, then use the feedback to decide what to revisit.

More practice: try new cases
1. Input amount is outside the contract before any write. Atomic model moves 3 tokens from A to B. Classify the recorded outcome.
Need a hint?
  • Commit the complete valid change or roll back the incomplete change.
  • Two successful-looking partial steps are not enough if their combined invariant is broken.
2. Request is read-only balance inspection. Atomic model moves 3 tokens from A to B. Classify the recorded outcome.
Need a hint?
  • Commit the complete valid change or roll back the incomplete change.
  • Two successful-looking partial steps are not enough if their combined invariant is broken.
3. Both required updates succeed and invariant holds. Atomic model moves 3 tokens from A to B. Classify the recorded outcome.
Need a hint?
  • Commit the complete valid change or roll back the incomplete change.
  • Two successful-looking partial steps are not enough if their combined invariant is broken.

Your choices are temporary. Feedback appears after you check all the answers.

Nothing here is saved to an account or sent to a teacher. Keep your own notes or download them before leaving. The score describes these questions; it does not certify subject mastery.

Check the subject sources

These LifeStarter passages, scenarios and exercises are authored for this Academy with AI assistance and review. External resources keep their publishers’ terms. A grade label suggests a starting level; it does not establish alignment with your school’s complete requirements.