【问题标题】:Implementing UNDO in DB transactions在 DB 事务中实现 UNDO
【发布时间】:2021-09-15 02:27:02
【问题描述】:

我正在实现一个嵌入式键值存储,并希望在其中支持事务。 这是我目前一直在研究的模型:

Basic operations supported :
- put(K,V)
- get(K)
- delete(K)

Steps for a put(K,V) :
- Log the K,V into a WAL and flush it to disk.
- Write the actual data on disk. [I do have buffering implemented but 
  we can ignore it for this question].

我读过的所有文献都谈到在日志记录中维护以下状态(在 WAL 中): TxId, OldValue, NewValue,其中 OldValue 用于 Undo,NewValue 用于 Redo。

我的问题是如何获得每个键 K 的 OldValue ?如果我需要为每个put(K,V) 操作搜索我的键值存储,即get(K),那么这将非常低效,因为我将每次写入与通过存储搜索前一个值联系起来(因为它可能不是存在于内存缓存中。)

【问题讨论】:

    标签: database transactions okvs


    【解决方案1】:

    这取决于 okvs 架构的其余部分。如果您使用日志/日志并且不更新磁盘上的表示,并且不支持嵌套事务,则不需要存储旧值。如果您使用 MVCC,您已经拥有旧值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-07
      • 2012-12-07
      • 2020-10-25
      • 2017-11-01
      • 2018-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多