| 452 | } |
| 453 | |
| 454 | void TupleCacheMgr::AbortWrite(UniqueHandle handle, bool tombstone) { |
| 455 | DCHECK(enabled_); |
| 456 | DCHECK(handle != nullptr && handle->cache_handle != nullptr); |
| 457 | DCHECK(handle->is_writer); |
| 458 | if (tombstone) { |
| 459 | VLOG_FILE << "Tuple Cache: Tombstone " << GetPath(handle); |
| 460 | tuple_cache_tombstones_in_use_->Increment(1); |
| 461 | // We update the write size to 0 to remove the existing cache charge |
| 462 | // (and decrement the outstanding writes counter) |
| 463 | UpdateWriteSize(handle.get(), 0); |
| 464 | CHECK(UpdateState(handle.get(), |
| 465 | TupleCacheState::IN_PROGRESS, TupleCacheState::TOMBSTONE)); |
| 466 | // We want the tombstone cache entry to have a base charge, so set that now |
| 467 | // (without counting towards the outstanding writes). |
| 468 | cache_->UpdateCharge(handle->cache_handle, handle->base_charge); |
| 469 | } else { |
| 470 | // Remove the cache entry. Leaves state IN_PROGRESS so entry won't be reused until |
| 471 | // successfully evicted. |
| 472 | DCHECK(TupleCacheState::IN_PROGRESS == GetState(handle.get())); |
| 473 | cache_->Erase(cache_->Key(handle->cache_handle)); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | Status TupleCacheMgr::RequestWriteSize(UniqueHandle* handle, size_t new_size) { |
| 478 | // The handle better be from a writer |