public Priority updatePriority(Priority oldPriority, long quantaNanos, long scheduledNanos) {
    int oldLevel = oldPriority.getLevel();
    int newLevel = computeLevel(scheduledNanos);

    long levelContribution = Math.min(quantaNanos, LEVEL_CONTRIBUTION_CAP);

    if (oldLevel == newLevel) {
      addLevelTime(oldLevel, levelContribution);
      return new Priority(oldLevel, oldPriority.getLevelScheduledTime() + quantaNanos);
    }

    long remainingLevelContribution = levelContribution;
    long remainingTaskTime = quantaNanos;

    // a task normally slowly accrues scheduled time in a level and then moves to the next, but
    // if the task had a particularly long quanta, accrue time to each level as if it had run
    // in that level up to the level limit.
    for (int currentLevel = oldLevel; currentLevel < newLevel; currentLevel++) {
      long timeAccruedToLevel =
          Math.min(
              SECONDS.toNanos(
                  (long) LEVEL_THRESHOLD_SECONDS[currentLevel + 1]
                      - (long) LEVEL_THRESHOLD_SECONDS[currentLevel]),
              remainingLevelContribution);
      addLevelTime(currentLevel, timeAccruedToLevel);
      remainingLevelContribution -= timeAccruedToLevel;
      remainingTaskTime -= timeAccruedToLevel;
    }

    addLevelTime(newLevel, remainingLevelContribution);
    // TODO figure out why add newLevelMinScheduledTime
    long newLevelMinScheduledTime = getLevelMinScheduledTime(newLevel, scheduledNanos);
    return new Priority(newLevel, newLevelMinScheduledTime + remainingTaskTime);
  }
MultilevelPriorityQueue charges the quanta run time to the task and the level it belongs to in
an effort to maintain the target thread utilization ratios between levels and to maintain
fairness within a level.

<p>Consider an example DriverTask where a read hung for several minutes. This is either a bug
or a failing dependency. In either case we do not want to charge the task too much, and we
especially do not want to charge the level too much - i.e. cause other queries in this level to
starve.

@return the new priority for the task
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/queue/multilevelqueue/MultilevelPriorityQueue.java