假设有两项业务对应的事务 T1、 T2与存款关系有关:
(1)转账业务: T1(A,B,50),从账户A向账户B转50元;
(2)计息业务: T2,对当前所有账户的余额计算利息,余额为X*1.01。
针对上述业务流程,回答下列问题:
【问题1】(3分)
假设当前账户A余额为100元,账户B余额为200元。有两个事务分别为 T1 (A,B,50),T2,一种可能的串行执行为:
T1(A, B, 50) → T2结果:A= 50.5 B=252.5 A+B=303
请给出其他的串行执行次序和结果。
【问题2】(8分)
若上述两个事务的一个并发调度结果如下:
(1)上述调度是否正确,为什么?(3分)
(2)引入共享锁指令Slock( )、独占锁指令Xlock( )和解锁指令Unlock( ),使上述调度满足两段锁协议,并要求先响应 T1的请求。请给出一个可能的并发调度结果。(5分)
【问题3】(4分)
若将计息业务 T2改为对单个账户的余额计算利息,即 T2 (A)余额为A*1.01,请给出串行调度 T1 (A,B,50) → T2(A) → T2(B)和串行调度 T2 (A) → T1 (A,B,50) → T2(B)的执行结果。
若将计息业务设计为对单个账户的余额计算利息,这种方案是否正确,为什么?
正确答案及解析
正确答案
解析
【问题1】(3分)
T2— T1 (A,B,50) 结果:A= 51 B=252 A+B = 303
【问题2】(8分)
(1)调度不正确
结果为:A= 50.5B=252
原因: 与任何一个串行结果都不同。
(2)满足两段锁协议的调度:
【问题3】(4分)
三个事务的串行:
(1)T1 (A,B,50)→T2 (A) →T2 (B)结果:A= 50.5 B=252.5
(2)T2 (A) →T1 (A,B,50)→T2(B)结果:A=51 B=252.5
不正确。计息业务设计为对单个账户的余额计算利息,无法实现对所有账户
统一计息,其间的转账会产生数据错误,会造成银行或客户的损失。
包含此试题的试卷
你可能感兴趣的试题
Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.
-
- A.Artificial Intelligence
- B.Cloud Computing
- C.Internet of Things
- D.Big Data
- 查看答案
In project human resource management , ( )is not a source of power for the project manager.
-
- A.referent power
- B.expert power
- C.reward power
- D.audit power
- 查看答案
At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.
-
- A.detail feasibility analysis
- B.opportunity analysis
- C.economic feasibility analysis
- D.risk analysis
- 查看答案
( )is a grid that shows the project resources assigned to each work package.
-
- A.Stakeholder engagement assessment matrix
- B.Requirements traceability matrix
- C.Probability and impact matrix
- D.Responsibility assignment matrix
- 查看答案
Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.
-
- A.digital
- B.networking
- C.intelligentize
- D.informatization
- 查看答案