Interface EvalJobRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<EvalJob,UUID>, org.springframework.data.jpa.repository.JpaRepository<EvalJob,UUID>, org.springframework.data.repository.ListCrudRepository<EvalJob,UUID>, org.springframework.data.repository.ListPagingAndSortingRepository<EvalJob,UUID>, org.springframework.data.repository.PagingAndSortingRepository<EvalJob,UUID>, org.springframework.data.repository.query.QueryByExampleExecutor<EvalJob>, org.springframework.data.repository.Repository<EvalJob,UUID>

public interface EvalJobRepository extends org.springframework.data.jpa.repository.JpaRepository<EvalJob,UUID>
  • Method Summary

    Modifier and Type
    Method
    Description
    claimNext(int maxAttempts)
    Atomically claims the oldest pending job below the retry ceiling using FOR UPDATE SKIP LOCKED, so multiple worker instances each pick a distinct job instead of blocking on, or double-processing, the same row.
    void
    deleteByConnectionId(UUID connectionId)
    Removes the queue records for a connection.
    boolean
     
     
     
    int
    Returns jobs claimed before the cutoff to PENDING so a job orphaned by a crashed worker is picked up again rather than stranded in CLAIMED forever.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • existsByRunAndEvaluatorName

      boolean existsByRunAndEvaluatorName(ExperimentRun run, String evaluatorName)
    • deleteByConnectionId

      @Modifying @Query("DELETE FROM EvalJob j WHERE j.connection.id = :connectionId") void deleteByConnectionId(@Param("connectionId") UUID connectionId)
      Removes the queue records for a connection. The eval results those jobs produced are untouched.
    • findByRunOrderByCreatedAtAsc

      List<EvalJob> findByRunOrderByCreatedAtAsc(ExperimentRun run)
    • claimNext

      @Query(value="SELECT * FROM eval_jobs\nWHERE status = \'PENDING\' AND attempt_count < :maxAttempts\nORDER BY created_at ASC\nLIMIT 1\nFOR UPDATE SKIP LOCKED\n", nativeQuery=true) Optional<EvalJob> claimNext(@Param("maxAttempts") int maxAttempts)
      Atomically claims the oldest pending job below the retry ceiling using FOR UPDATE SKIP LOCKED, so multiple worker instances each pick a distinct job instead of blocking on, or double-processing, the same row. Must run inside a transaction.
      Parameters:
      maxAttempts - the retry ceiling; jobs at or above this count are skipped
      Returns:
      the locked candidate job, if any
    • requeueStaleClaims

      @Modifying @Query("UPDATE EvalJob j\nSET j.status = dev.dokimos.server.entity.EvalJobStatus.PENDING\nWHERE j.status = dev.dokimos.server.entity.EvalJobStatus.CLAIMED\nAND j.claimedAt < :cutoff\n") int requeueStaleClaims(@Param("cutoff") Instant cutoff)
      Returns jobs claimed before the cutoff to PENDING so a job orphaned by a crashed worker is picked up again rather than stranded in CLAIMED forever. The attempt count is left as-is, so the retry ceiling still bounds how many times a job is reclaimed.
      Parameters:
      cutoff - jobs claimed before this instant are requeued
      Returns:
      the number of jobs requeued
    • findByStatus

      List<EvalJob> findByStatus(EvalJobStatus status)