【发布时间】:2015-02-16 10:43:03
【问题描述】:
我正在学习基于时间戳的协议。我试图创建一个活生生的例子,但我不确定这是否正确。
每个事务 Ti 都有时间戳 ts(Ti)
If a transaction Ti issues read(X) operation:
If TS(Ti) < W-timestamp(X)
Operation rejected.
If TS(Ti) >= W-timestamp(X)
Read Operation executed. We set R-timestamp(x) = max(ts(T), R-timestamp(x)
All data-item Timestamps updated.
为了创建一个实际示例,我制作了这个非常简单的 Excel 公式(其中 C1 是 TS(Ti),D1 是 x 的 W 时间戳:
=IF(C1<D1,"TRUE","FALSE")
所以我输入:
(C1) (C2)
TS(Ti) | W-Timestamp |
01/02/2015 | 03/02/2015 | TRUE
在第一个日期,事务(早于 stamp)正在尝试读取已由较新事务更新的值。由于Ti<W-timestamp 是True,我们中止事务并使用新的时间戳重新开始。
这是否意味着TS(Ti) 的日期现在变为03/02/2015?所以如果我们再次测试:
Execute If: (03/02/2015 >= 03/02/2015) = True
然后我们需要设置R-timestamp(x) = max(ts(T), R-timestamp(x)
所以我们最终得到:
TS = 03/02/2015
W-timestamp = 03/02/2015
R-timestamp = 03/02/2015 <- is this correct, not sure what to do here.
如果这个实际例子正确吗? R-时间戳到底发生了什么?
【问题讨论】:
标签: database concurrency transactions timestamp