/* * Updating accounting of size when closing a persistent file we created */ static void adjust_size_persistent_file_new(workfile_set *work_set, int64 size) { #if USE_ASSERT_CHECKING bool isCached = (NULL != work_set) && Cache_IsCached(CACHE_ENTRY_HEADER(work_set)); #endif Assert(NULL != work_set && !isCached); work_set->size += size; elog(gp_workfile_caching_loglevel, "closed new persistent file, added size " INT64_FORMAT " to set space", size); }
/* * Updating accounting of size when closing an existing persistent file * we opened for reading */ static void adjust_size_persistent_file_existing(workfile_set *work_set, int64 size) { #if USE_ASSERT_CHECKING bool isCached = (NULL != work_set) && Cache_IsCached(CACHE_ENTRY_HEADER(work_set)); #endif AssertEquivalent((NULL != work_set), isCached); elog(gp_workfile_caching_loglevel, "closing existing persistent file, nothing to do"); return; }
/* * Updating accounting of size when closing a temporary file we created */ static void adjust_size_temp_file_new(workfile_set *work_set, int64 size) { #if USE_ASSERT_CHECKING bool isCached = (NULL != work_set) && Cache_IsCached(CACHE_ENTRY_HEADER(work_set)); #endif Assert(!isCached); AssertImply((NULL != work_set), work_set->size == 0); AssertImply((NULL != work_set), work_set->in_progress_size >= size); if (NULL != work_set) { work_set->in_progress_size -= size; } WorkfileDiskspace_Commit(0, size, true /* update_query_size */); elog(gp_workfile_caching_loglevel, "closed and deleted temp file, subtracted size " INT64_FORMAT " from disk space", size); }
/* * Updating accounting of size when closing a temporary file we created */ static void adjust_size_temp_file_new(workfile_set *work_set, int64 size) { #if USE_ASSERT_CHECKING bool isCached = (NULL != work_set) && Cache_IsCached(CACHE_ENTRY_HEADER(work_set)); #endif Assert(!isCached); AssertImply((NULL != work_set), work_set->size == 0); AssertImply((NULL != work_set), work_set->in_progress_size >= size); if (NULL != work_set) { work_set->in_progress_size -= size; } WorkfileDiskspace_Commit(0 /* commit_bytes */, size, true /* update_query_size */); elog(gp_workfile_caching_loglevel, "closed and deleted temp file, subtracted size " INT64_FORMAT " from disk space", size); /* About to physically delete a file we created. Update the per-query file count as well */ WorkfileQueryspace_SubtractWorkfile(1 /* nFiles */); }
/* * Close a spill file set. If we're planning to re-use it, insert it in the * cache. If not, let the cleanup routine delete the files and free up memory. */ void workfile_mgr_close_set(workfile_set *work_set) { Assert(work_set!=NULL); elog(gp_workfile_caching_loglevel, "closing workfile set: can_be_reused=%d complete=%d location: %s, size=" INT64_FORMAT " in_progress_size=" INT64_FORMAT, work_set->can_be_reused, work_set->complete, work_set->path, work_set->size, work_set->in_progress_size); CacheEntry *cache_entry = CACHE_ENTRY_HEADER(work_set); if (Cache_IsCached(cache_entry)) { /* Workset came from cache. Just release it, nothing to do */ Cache_Release(workfile_mgr_cache, cache_entry); return; } if (work_set->complete && work_set->can_be_reused) { cache_entry->size = work_set->size; /* We want to keep this one around. Insert into cache */ Cache_Insert(workfile_mgr_cache, cache_entry); Cache_Release(workfile_mgr_cache, cache_entry); return; } /* * Fall-through case: We need to delete this work_set, as it's not reusable. */ Assert(!work_set->complete || !work_set->can_be_reused); Cache_Release(workfile_mgr_cache, cache_entry); }