0

我们有一个 sybase ASE 15 DB,上周发生了一些奇怪的事情,看起来新插入的行上的选择可能在插入后立即丢失

我们的表使用开始/结束时间戳进行里程碑;一个例子是

id number,
name varchar(32),
start timestamp,
end timestamp;

“更新”将是对现有端的更新;并插入新记录;例如

id name  start               end
1  alice 2010-01-01 00:00:00 3000-01-01 00:00:00

在更新将成为

id name  start               end
1  alice 2010-01-01 00:00:00 2010-01-01 08:00:00
1  bob   2010-01-01 08:00:00 3000-01-01 00:00:00

并且更新和插入都在同一个事务中完成

现在在(id,start,end)上使用行锁定和索引,当使用隔离级别1进行选择时,使用select查询:

select * from table where id=1 and start<=getdate() and end>getdate()

理想情况下,当 select 在更新期间运行时,它应该阻塞直到提交并返回最新行。

然而,在我们的例子中,我们看到了阻塞,但没有返回任何行!

This means to me that when the select is run, it sees the update but not the insert; 那可能吗?

是否有可能在提交时以某种方式插入新行但未更新索引因此选择没有看到新行?

谢谢

4

1 回答 1

0

如果这是 Sybase ASE,那么您必须选择与“timestamp”不同的数据类型——这是 ASE 中的一种特殊数据类型,与实际日期/时间无关。请改用“bigdatetime”或“datetime”。

于 2017-05-24T10:45:06.800 回答