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版本
版权声明:本文为bupt041137原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。