Non-repeatable read

Non-repeatable read happens when a transaction reads the same data twice with different results. For example, in transaction A, consider reading data item C. Before transaction A completes, transaction B changes and commits data item C. A later operation within transaction A reads the same data again and sees a new value of data C. The first data read in transaction A can be considered non-repeatable because transaction B's change has been allowed to work into the context of the transaction A. To simulate this read, we can execute these operations:

...
readAccount
.setAccountNumber(345);
readAccount.setFirstWaitTime(0);
readAccount.setSecondWaitTime(2000);
writeAccount.setAccountNumber(345);
writeAccount.setAmount(456.77);
writeAccount.setWaitTime(1000);
defaultExecutor.submit(writeAccount);
defaultExecutor.submit(readAccount);

The operations can be simplified so:

  • The first transaction starts and we have a first read of account 345
  • The second transaction starts and an update of the credit of 456.77 is done in account 345
  • The second transaction ends
  • A second read of account 345 is done in the first transaction
  • The first transaction ends
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.181.52