English 中文(简体)
当事务在时间戳排序协议中回滚时,为什么会给它一个新的时间戳?
原标题:When a transaction is rolled back in timestamp ordering protocol why is it given a new timestamp?

When a transaction is rolled back in timestamp ordering protocol, why is it given a new timestamp? Why don`t we retain the old timestamp?

问题回答

如果您谈论的是一个调度器,其操作是基于时间戳的,并且回滚的事务被允许使用其旧的时间戳“重新进入调度队列”,那么净效果可能是调度器立即为来自该事务的任何请求赋予最高优先级,这样做的净效果可能是,无论什么问题导致该事务回滚,都会几乎立即重新出现,可能会导致新的回滚,从而导致新的“重新进入计划队列”,等等。

或者,“立即重新进入队列”的净效果可能是所有其他事务都被搁置。

想象一下邮局里的一队人,有人提出了一个无法送达的请求,这个人被允许立即重新进入前面(而不是后面)的队列。那要等多久才能轮到你呢?

因为可能还有其他事务使用新的时间戳提交

  • Initial timestamp is at X
  • Transaction T1 starts
  • T1 allocates timestamp increments it to value to X+1
  • Transaction T2 starts
  • T2 allocates timestamp increments it to value to X+2
  • T2 commits
  • T1 rolls back

如果T1将时间戳回滚到X,则第三事务将与T2的分配值产生冲突。增量和序列也是如此。如果您需要单片序列值(没有间隙),那么事务必须序列化,而这是以糟糕的性能为代价的。

在时间戳排序协议中,启动时分配给事务的时间戳用于识别与其他事务的潜在冲突。这些事务可能是更新了该事务试图读取的对象的事务,也可能是读取该事务试图覆盖的值的事务。因此,当事务中止并重新启动(即,为了保持可串行性)时,事务的所有操作都将重新执行,这就是需要分配新时间戳的原因。

从理论角度来看,当事务仍在使用旧的时间戳时再次重新运行操作是不正确的&;不安全,因为它会读取/覆盖新的值,同时认为它位于一个旧的时刻。从实际的角度来看,如果事务继续使用旧的时间戳,那么它很可能会继续中止&;不断地重新启动,因为它将一次又一次地与相同的事务发生冲突。





相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签