berkeley db xa

正常流程:

txn/txn.c, 

__txn_prepare(), 对比 __txn_commit(). 基本只差了 写一个 commit log rec; 释放写锁; 释放内存数据结构等.

td->status = TXN_PREPARED;

 

__txn_abort(), 对 已经TXN_PREPARED 的txn, 写一条TXN_ABORT log rec(一般不写的).

 

__txn_commit(), 若出错, 对TXN_PREPARED, panic, 做env recovery. 因为对应的log已经在disk上, 保证此txn所做的修改不会丢失. 见下面的recover过程.

 

恢复

env/env_recover.c, 把log 滚来滚去哈

db/db_dispatch.c, __db_dispatch() - 对应某个log rec, 根据其log rec type发送给不同的 recover处理函数.

 

txn/txn_rec.c,

__txn_prepare_recover():

On the backward pass, we have four possibilities:
* 1. The transaction is already committed, no-op.
* 2. The transaction is already aborted, no-op.
* 3. The prepare failed and was aborted, mark as abort.
* 4. The transaction is neither committed nor aborted.
* Treat this like a commit and roll forward so that
* the transaction can be resurrected in the region.
* We handle cases 3 and 4 here; cases 1 and 2
* are the final clause below.

 这个是 对应于向前回滚的 阶段(recover, 向前rollback, 在向后redo). 当看到一条prepare log rec时, 

1, 2. 如果 已经看到 此txn的commit/abort log rec(注意是向前滚), no-op;

4. 如果prepare log rec后面没有看到commit/abort log, 按commit处理. 这个是没有问题的, 因为我们有此txn所有完整的 log;

3. 什么情况? - TODO

转载于:https://www.cnblogs.com/brayden/p/5278809.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值