def METHOD_NAME():
    """
    Attempt to process one job from the job queue. Returns False if no job was found, True if a job was processed,
    regardless of failure/success.
    """
    logger.debug(f"Looking for a job")
    with session_scope(isolation_level="REPEATABLE READ") as session:
        # a combination of REPEATABLE READ and SELECT ... FOR UPDATE SKIP LOCKED makes sure that only one transaction
        # will modify the job at a time. SKIP UPDATE means that if the job is locked, then we ignore that row, it's
        # easier to use SKIP LOCKED vs NOWAIT in the ORM, with NOWAIT you get an ugly exception from deep inside
        # psycopg2 that's quite annoying to catch and deal with
        job = (
            session.execute(
                select(BackgroundJob).where(BackgroundJob.ready_for_retry).with_for_update(skip_locked=True)
            )
            .scalars()
            .first()
        )
        if not job:
            logger.debug(f"No pending jobs")
            return False
        # we've got a lock for a job now, it's "pending" until we commit or the lock is gone
        logger.info(f"Job #{job.id} grabbed")
        job.try_count += 1
        message_type, func = JOBS[job.job_type]
        try:
            ret = func(message_type.FromString(job.payload))
            job.state = BackgroundJobState.completed
            jobs_counter.labels(job.job_type.name, job.state.name, str(job.try_count), "").inc()
            logger.info(f"Job #{job.id} complete on try number {job.try_count}")
        except Exception as e:
            logger.exception(e)
            sentry_sdk.set_tag("context", "job")
            sentry_sdk.set_tag("job", job.job_type.name)
            sentry_sdk.capture_exception(e)
            if job.try_count >= job.max_tries:
                # if we already tried max_tries times, it's permanently failed
                job.state = BackgroundJobState.failed
                logger.info(f"Job #{job.id} failed on try number {job.try_count}")
            else:
                job.state = BackgroundJobState.error
                # exponential backoff
                job.next_attempt_after += timedelta(seconds=15 * (2**job.try_count))
                logger.info(f"Job #{job.id} error on try number {job.try_count}, next try at {job.next_attempt_after}")
            # add some info for debugging
            jobs_counter.labels(job.job_type.name, job.state.name, str(job.try_count), type(e).__name__).inc()
            job.failure_info = traceback.format_exc()
        # exiting ctx manager commits and releases the row lock
    return True