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

Function ResLockRelease

src/backend/utils/resscheduler/resqueue.c:622–845  ·  view source on GitHub ↗

* ResLockRelease -- release a resource lock. * * The "locktag" here consists of the queue-id and the "lockmethod" of * "resource-queue" and an identifier specifying that this is a * resource-locktag. */

Source from the content-addressed store, hash-verified

620 * resource-locktag.
621 */
622bool
623ResLockRelease(LOCKTAG *locktag, uint32 resPortalId)
624{
625 LOCKMODE lockmode = ExclusiveLock;
626 LOCK *lock;
627 PROCLOCK *proclock;
628 LOCALLOCKTAG localtag;
629 LOCALLOCK *locallock;
630 uint32 hashcode;
631 LWLockId partitionLock;
632 ResourceOwner owner;
633
634 ResPortalIncrement *incrementSet;
635 ResPortalTag portalTag;
636 bool resLockAcquireOrReleaseInterrupted = false;
637
638 /* Check the lock method bits. */
639 Assert(locktag->locktag_lockmethodid == RESOURCE_LOCKMETHOD);
640
641 /* Check whether previous ResLockAcquire() was interrupted. */
642 if (resLockAcquireStatus != RQA_NOT_STARTED_OR_DONE)
643 {
644 elog(LOG,
645 "Resource queue %d: previous ResLockAcquire() interrupted, "
646 " status = %d, portal id = %u",
647 locktag->locktag_field1,
648 resLockAcquireStatus,
649 resPortalId);
650 resLockAcquireOrReleaseInterrupted = true;
651 }
652
653 /*
654 * ResLockRelease() might re-enter.
655 * Check whether previous ResLockRelease() was interrupted.
656 */
657 if (resLockReleaseStatus != RQR_NOT_STARTED_OR_DONE)
658 {
659 elog(LOG,
660 "Resource queue %d: previous ResLockRelease() interrupted, "
661 " status = %d, portal id = %u",
662 locktag->locktag_field1,
663 resLockReleaseStatus,
664 resPortalId);
665 resLockAcquireOrReleaseInterrupted = true;
666 }
667 resLockReleaseStatus = RQR_STARTED;
668
669 /* Provide a resource owner. */
670 owner = CurrentResourceOwner;
671
672 /*
673 * Find the LOCALLOCK entry for this lock and lockmode
674 */
675 MemSet(&localtag, 0, sizeof(localtag)); /* must clear padding */
676 localtag.lock = *locktag;
677 localtag.mode = lockmode;
678
679 locallock = (LOCALLOCK *)

Callers 3

ResLockPortalFunction · 0.85
ResLockUtilityPortalFunction · 0.85
ResUnLockPortalFunction · 0.85

Calls 10

hash_searchFunction · 0.85
DumpResQueueLockInfoFunction · 0.85
RemoveLocalLockFunction · 0.85
LWLockAcquireFunction · 0.85
LWLockReleaseFunction · 0.85
ResCleanUpLockFunction · 0.85
ResIncrementFindFunction · 0.85
ResUnGrantLockFunction · 0.85
ResLockUpdateLimitFunction · 0.85
ResIncrementRemoveFunction · 0.85

Tested by

no test coverage detected