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

Function release_shareinput_reference

src/backend/executor/nodeShareInputScan.c:870–900  ·  view source on GitHub ↗

* Release reference to a shared scan. * * The reference count in the shared memory slot is decreased, and if * it reaches zero, it is destroyed if not in reader squelching. * The reference is also removed from the list of references tracked by * the current ResourceOwner. * * NB: We don't want to destroy the shared state if in reader squelching, * because there might be other readers or wr

Source from the content-addressed store, hash-verified

868 * it. So leave the work to the producer.
869 */
870static void
871release_shareinput_reference(shareinput_Xslice_reference *ref, bool reader_squelching)
872{
873 shareinput_Xslice_state *state = ref->xslice_state;
874
875 LWLockAcquire(ShareInputScanLock, LW_EXCLUSIVE);
876 state->refcount--;
877 elog((Debug_shareinput_xslice ? LOG : DEBUG1), "SISC (shareid=%d, slice=%d): decreased xslice state refcount to %d",
878 state->tag.share_id, currentSliceId, state->refcount);
879
880 if (!reader_squelching && state->refcount == 0)
881 {
882 bool found;
883
884 (void) hash_search(shareinput_Xslice_hash,
885 &state->tag,
886 HASH_REMOVE,
887 &found);
888 Assert(found);
889 elog((Debug_shareinput_xslice ? LOG : DEBUG1), "SISC (shareid=%d, slice=%d): removed xslice state",
890 state->tag.share_id, currentSliceId);
891 }
892 else if (state->refcount == 0)
893 SIMPLE_FAULT_INJECTOR("get_shareinput_reference_done");
894
895 dlist_delete(&ref->node);
896
897 LWLockRelease(ShareInputScanLock);
898
899 pfree(ref);
900}
901
902/*
903 * Callback to release references on transaction abort.

Callers 3

ExecEndShareInputScanFunction · 0.85

Calls 5

LWLockAcquireFunction · 0.85
hash_searchFunction · 0.85
dlist_deleteFunction · 0.85
LWLockReleaseFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected