| 1371 | } |
| 1372 | |
| 1373 | void TmpFileGroup::Close() { |
| 1374 | // Cancel writes before deleting the files, since in-flight writes could re-create |
| 1375 | // deleted files. |
| 1376 | if (io_ctx_ != nullptr) { |
| 1377 | if (tmp_file_mgr_->HasRemoteDir()) { |
| 1378 | // Remove all the writes using the io_ctx and waiting for buffer reservation in |
| 1379 | // the pool. |
| 1380 | DCHECK(tmp_file_mgr_->tmp_dirs_remote_ctrl_.tmp_file_pool_ != nullptr); |
| 1381 | tmp_file_mgr_->tmp_dirs_remote_ctrl_.tmp_file_pool_->RemoveWriteRanges( |
| 1382 | io_ctx_.get()); |
| 1383 | } |
| 1384 | io_mgr_->UnregisterContext(io_ctx_.get()); |
| 1385 | } |
| 1386 | CloseInternal<std::unique_ptr<TmpFile>>(tmp_files_); |
| 1387 | CloseInternal<std::shared_ptr<TmpFile>>(tmp_files_remote_); |
| 1388 | tmp_file_mgr_->RemoveRemoteDirForQuery(this); |
| 1389 | tmp_file_mgr_->scratch_bytes_used_metric_->Increment( |
| 1390 | -1 * scratch_space_bytes_used_counter_->value()); |
| 1391 | } |
| 1392 | |
| 1393 | // Rounds up to the smallest unit of allocation in a scratch file |
| 1394 | // that will fit 'bytes'. |
nothing calls this directly
no test coverage detected