| 1600 | } |
| 1601 | |
| 1602 | void TmpFileGroup::RecycleFileRange(unique_ptr<TmpWriteHandle> handle) { |
| 1603 | TmpFile* file = handle->file_; |
| 1604 | int64_t space_used_bytes = |
| 1605 | RoundUpToScratchRangeSize(tmp_file_mgr_->punch_holes(), handle->on_disk_len()); |
| 1606 | if (tmp_file_mgr_->punch_holes()) { |
| 1607 | Status status = file->PunchHole(handle->write_range_->offset(), space_used_bytes); |
| 1608 | if (!status.ok()) { |
| 1609 | // Proceed even in the hole punching fails - we will use extra disk space but |
| 1610 | // functionally we can continue to spill. |
| 1611 | LOG_EVERY_N(WARNING, 100) << "Failed to punch hole in scratch file, couldn't " |
| 1612 | << "reclaim space: " << status.GetDetail(); |
| 1613 | return; |
| 1614 | } |
| 1615 | scratch_space_bytes_used_counter_->Add(-space_used_bytes); |
| 1616 | tmp_file_mgr_->scratch_bytes_used_metric_->Increment(-space_used_bytes); |
| 1617 | current_bytes_allocated_.Add(-space_used_bytes); |
| 1618 | } else { |
| 1619 | // For the remote files, we don't recycle the file and range because the remote file |
| 1620 | // is not allowed to in-place modification. |
| 1621 | if (file->DiskFile()->disk_type() == io::DiskFileType::LOCAL) { |
| 1622 | int free_ranges_idx = BitUtil::Log2Ceiling64(space_used_bytes); |
| 1623 | lock_guard<SpinLock> lock(lock_); |
| 1624 | free_ranges_[free_ranges_idx].emplace_back(file, handle->write_range_->offset()); |
| 1625 | } |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | Status TmpFileGroup::Write(MemRange buffer, WriteDoneCallback cb, |
| 1630 | unique_ptr<TmpWriteHandle>* handle, const BufferPoolClientCounters* counters) { |
nothing calls this directly
no test coverage detected