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

Function ResLockUpdateLimit

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

* ResLockUpdateLimit -- update the resource counter for this lock with the * increment for the process. * * Notes: * If increment is true, then the resource counter associated with the lock * is to be incremented, if false then decremented. * * Warnings: * The resource queue lightweight lock (ResQueueLock) must be held while * this function is called. */

Source from the content-addressed store, hash-verified

1018 * this function is called.
1019 */
1020void
1021ResLockUpdateLimit(LOCK *lock, PROCLOCK *proclock, ResPortalIncrement *incrementSet, bool increment, bool inError)
1022{
1023 ResQueue queue;
1024 ResLimit limits;
1025 Cost increment_amt;
1026 int i;
1027
1028 Assert(LWLockHeldByMeInMode(ResQueueLock, LW_EXCLUSIVE));
1029
1030 /* Get the queue for this lock. */
1031 queue = GetResQueueFromLock(lock);
1032 limits = queue->limits;
1033
1034 /*
1035 * If inError is true, dump the rq info and stack to track
1036 * where ResLockUpdateLimit() was called.
1037 */
1038 if (inError)
1039 {
1040 Assert(limits[0].type == RES_COUNT_LIMIT);
1041 elog(LOG,
1042 "Resource queue id: %u, count limit: %f, portal id: %u\n",
1043 queue->queueid,
1044 limits[0].current_value,
1045 incrementSet->portalId);
1046 ereport(LOG,
1047 (errmsg("ResLockUpdateLimit()"),
1048 errprintstack(true)));
1049 }
1050
1051 for (i = 0; i < NUM_RES_LIMIT_TYPES; i++)
1052 {
1053 /*
1054 * MPP-8454: NOTE that if our resource-queue has been modified since
1055 * we locked our resources, on unlock it is possible that we're
1056 * deducting an increment that we never added -- the lowest value we
1057 * should allow is 0.0.
1058 *
1059 */
1060 switch (limits[i].type)
1061 {
1062 case RES_COUNT_LIMIT:
1063 case RES_COST_LIMIT:
1064 case RES_MEMORY_LIMIT:
1065 {
1066 Cost new_value;
1067
1068 Assert((limits[i].threshold_is_max));
1069 /* setup whether to increment or decrement the # active. */
1070 if (increment)
1071 {
1072 increment_amt = incrementSet->increments[i];
1073 }
1074 else
1075 {
1076 increment_amt = -1 * incrementSet->increments[i];
1077 }

Callers 4

ResLockAcquireFunction · 0.85
ResLockReleaseFunction · 0.85
ResCheckSelfDeadLockFunction · 0.85

Calls 4

LWLockHeldByMeInModeFunction · 0.85
GetResQueueFromLockFunction · 0.85
errmsgFunction · 0.50
errprintstackFunction · 0.50

Tested by

no test coverage detected