to verify the inconsistency of transaction processing.
In session A, the price is 1000 yen plus 1000 yen to 2000 yen, and
After that, I will try to increase the price to 1000 yen and 5000 yen for the B session to confirm that it is not consistent.
According to my prediction, it should have been 6000 yen for B session, but when B session is updated, it becomes wait and A session B session moves correctly and becomes 7000 yen.
In that case, I thought only transactions would be fine.
I thought it was necessary to lock the line of the transaction...
I believe that the transaction was carried out at the default Read Committed isolation level.
https://www.postgresql.jp/document/13/html/transaction-iso.html#XACT-READ-COMMITTED
As you can see here, the behavior of the update at Read Committed is as follows:
As a result of this behavior, an excerpt from the above document says that if the update is written using the original value as shown below, this will be the result as intended.
BEGIN;
UPDATE accounts SET balance=balance+100.00 WHERE acctnum=12345;
UPDATE accounts SET balance=balance-100.00 WHERE acctnum=7534;
COMMIT;
585 PHP ssh2_scp_send fails to send files as intended
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
619 GDB gets version error when attempting to debug with the Presense SDK (IDE)
626 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.