MCPcopy Create free account
hub / github.com/apache/cloudberry / SharedFileSetOnDetach

Function SharedFileSetOnDetach

src/backend/storage/file/sharedfileset.c:240–259  ·  view source on GitHub ↗

* Callback function that will be invoked when this backend detaches from a * DSM segment holding a SharedFileSet that it has created or attached to. If * we are the last to detach, then try to remove the directories and * everything in them. We can't raise an error on failures, because this runs * in error cleanup paths. */

Source from the content-addressed store, hash-verified

238 * in error cleanup paths.
239 */
240static void
241SharedFileSetOnDetach(dsm_segment *segment, Datum datum)
242{
243 bool unlink_all = false;
244 SharedFileSet *fileset = (SharedFileSet *) DatumGetPointer(datum);
245
246 SpinLockAcquire(&fileset->mutex);
247 Assert(fileset->refcnt > 0);
248 if (--fileset->refcnt == 0)
249 unlink_all = true;
250 SpinLockRelease(&fileset->mutex);
251
252 /*
253 * If we are the last to detach, we delete the directory in all
254 * tablespaces. Note that we are still actually attached for the rest of
255 * this function so we can safely access its data.
256 */
257 if (unlink_all)
258 SharedFileSetDeleteAll(fileset);
259}
260
261/*
262 * Callback function that will be invoked on the process exit. This will

Callers

nothing calls this directly

Calls 1

SharedFileSetDeleteAllFunction · 0.85

Tested by

no test coverage detected