log4j log time point thread number operation database action
2017-10-21 12:32:52,804 http-bio-8080-exec-150 select TOTAL_DAY_LIMIT null then insert 0 commit;
2017-10-21 12:32:52,842 http-bio-8080-exec-152 select TOTAL_DAY_LIMIT 0
2017-10-21 12:32:53,224 http-bio-8080-exec-150 update TOTAL_DAY_LIMIT+1--->TOTAL_DAY_LIMIT='1' commit;
2017-10-21 12:32:53,325 http-bio-8080-exec-153 select TOTAL_DAY_LIMIT 1
2017-10-21 12:32:53,475 http-bio-8080-exec-152 update TOTAL_DAY_LIMIT+1--->TOTAL_DAY_LIMIT='2' commit;
2017-10-21 12:32:53,564 http-bio-8080-exec-154select TOTAL_DAY_LIMIT 2 limit exceeded, transaction rejected
2017-10-21 12:32:53,718 http-bio-8080-exec-153 update TOTAL_DAY_LIMIT+1--->TOTAL_DAY_LIMIT='3' commit;
Normal transaction process: The customer's single-day cumulative limit is 2 yuan (TOTAL_DAY_LIMIT), 4 concurrent transactions, each transaction is 1 yuan, when the customer consumes the third transaction, the limit exceeds the limit and the transaction is rejected.
The database should record a limit of 2 yuan (TOTAL_DAY_LIMIT)
Actual transaction process: The customer's single-day cumulative limit is 2 yuan (TOTAL_DAY_LIMIT), and 4 transactions are concurrently made, each transaction is 1 yuan. When the customer consumes the fourth transaction, the limit exceeds the limit and the transaction is rejected.
The database should record a limit of 3 yuan (TOTAL_DAY_LIMIT) for the reasons above.
Is there a good solution? Follow the normal transaction process.