* 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
| 868 | * it. So leave the work to the producer. |
| 869 | */ |
| 870 | static void |
| 871 | release_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. |
no test coverage detected