`
bupt04406
  • 浏览: 344007 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

hbase flush前提: 等待相关事务都完成

 
阅读更多
DefaultMemStore:
  @Override
  public void rollback(Cell cell) {
    // If the key is in the snapshot, delete it. We should not update
    // this.size, because that tracks the size of only the memstore and
    // not the snapshot. The flush of this snapshot to disk has not
    // yet started because Store.flush() waits for all rwcc transactions to
    // commit before starting the flush to disk.
    Cell found = this.snapshot.get(cell);
    if (found != null && found.getSequenceId() == cell.getSequenceId()) {
      this.snapshot.remove(cell);
      long sz = heapSizeChange(cell, true);
      this.snapshotSize -= sz;
    }
    // If the key is in the memstore, delete it. Update this.size.
    found = this.cellSet.get(cell);
    if (found != null && found.getSequenceId() == cell.getSequenceId()) {
      removeFromCellSet(cell);
      long s = heapSizeChange(cell, true);
      this.size.addAndGet(-s);
    }
  }

 

 

这段代码里面有段注释:

 The flush of this snapshot to disk has not yet started because Store.flush() waits for all rwcc transactions to

 commit before starting the flush to disk.

flush之前会等之前的事务都完成。

 

 我们来看下flush相关逻辑:

HRegion:
  protected PrepareFlushResult internalPrepareFlushCache(final WAL wal, final long myseqid,
      final Collection<Store> storesToFlush, MonitoredTask status, boolean writeFlushWalMarker)
      throws IOException {
        。。。
        writeEntry = mvcc.beginMemstoreInsert();
      // wait for all in-progress transactions to commit to WAL before
      // we can start the flush. This prevents
      // uncommitted transactions from being written into HFiles.
      // We have to block before we start the flush, otherwise keys that
      // were removed via a rollbackMemstore could be written to Hfiles.
      mvcc.waitForPreviousTransactionsComplete(writeEntry);
        。。。
  }

 

 代码是1.1.2版本

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics