Unverified Commit c088f9c0 authored by mvdbeek's avatar mvdbeek
Browse files

Rebuild caches after clearing cache

and before incrementing in-memory structures.
parent 1628fffb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -518,6 +518,9 @@ class JobHandlerQueue(BaseJobHandlerQueue):
                pass
        # Ensure that we get new job counts on each iteration
        self.__clear_job_count()
        self.__cache_total_job_count_per_destination()
        self.__cache_user_job_count_per_destination()
        self.__cache_user_job_count()
        # Check resubmit jobs first so that limits of new jobs will still be enforced
        for job in resubmit_jobs:
            log.debug("(%s) Job was resubmitted and is being dispatched immediately", job.id)
@@ -824,7 +827,6 @@ class JobHandlerQueue(BaseJobHandlerQueue):
        self.total_job_count_per_destination = None

    def get_user_job_count(self, user_id):
        self.__cache_user_job_count()
        # This could have been incremented by a previous job dispatched on this iteration, even if we're not caching
        rval = self.user_job_count.get(user_id, 0)
        if not self.app.config.cache_user_job_count:
@@ -865,7 +867,6 @@ class JobHandlerQueue(BaseJobHandlerQueue):
            self.user_job_count = {}

    def get_user_job_count_per_destination(self, user_id):
        self.__cache_user_job_count_per_destination()
        cached = self.user_job_count_per_destination.get(user_id, {})
        if self.app.config.cache_user_job_count:
            rval = cached
@@ -1006,7 +1007,6 @@ class JobHandlerQueue(BaseJobHandlerQueue):
                self.total_job_count_per_destination[row["destination_id"]] = row["job_count"]

    def get_total_job_count_per_destination(self):
        self.__cache_total_job_count_per_destination()
        # Always use caching (at worst a job will have to wait one iteration,
        # and this would be more fair anyway as it ensures FIFO scheduling,
        # insofar as FIFO would be fair...)