Rocksdb 写数据流程

writeImpl

大致流程:

  • 一般都要先做一些参数check
  • 写wal
  • 写memtable
  • 更新seq
  • 收尾
  • 流程结束并返回

重要知识点:

  • joinBatchGroup相关的status操作
  • 写wal的注意事项
  • 写memtable的内部流程(跳表)
  • sequence相关操作


细节流程

=============mutex_.Lock();============
  • step12
    • PreprocessWrite
  • step13
    • log::Writer* log_writer = logs_.back().writer;
============mutex_.Unlock();============

  • step 14:
    • EnterAsBatchGroupLeader
  • step15
    • 计算stats
  • step16
    • 更新stats
  • step17
    • 判断write_done_by_other  更新stats WRITE_DONE_BY_OTHER
  • step18
    • a
      • // A flag indicating whether the current rocksdb database has any
        // data that is not yet persisted into either WAL or SST file.
        // Used when disableWAL is true.标识当前rocksdb数据库是否有任何尚未持久化到WAL或SST文件中的数据。
  • step19
    • WriteToWAL或者ConcurrentWriteToWAL
    • FetchAddLastAllocatedSequence!!!
  • step20
    • inc seq number for memtable writes
    • pre_release_callback  (事务场景用到)
  • step21
    • WriteBatchInternal::InsertInto  写memtable
  • step22
    • FlushWal  or   SyncWal
  • step23
    • in_parallel_group=true的话,执行CompleteParallelMemTableWriter
  • step24
    • 更新versions_->SetLastSequence(last_sequence);
    • MemTableInsertStatusCheck
  • step25
    • 获取w.FinalStatus()
    • 返回status;

结束

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值