Usage server should takeover immediately if the other Usage server has been stopped gracefully (#12507)

This commit is contained in:
Abhisar Sinha 2026-01-28 19:38:25 +05:30 committed by GitHub
parent 35e6d7c5ba
commit 95de88a8ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View File

@ -28,6 +28,8 @@ public interface UsageJobDao extends GenericDao<UsageJobVO, Long> {
UsageJobVO getLastJob();
UsageJobVO getNextRecurringJob();
UsageJobVO getNextImmediateJob();
long getLastJobSuccessDateMillis();

View File

@ -156,7 +156,8 @@ public class UsageJobDaoImpl extends GenericDaoBase<UsageJobVO, Long> implements
return jobs.get(0);
}
private UsageJobVO getNextRecurringJob() {
@Override
public UsageJobVO getNextRecurringJob() {
Filter filter = new Filter(UsageJobVO.class, "id", false, Long.valueOf(0), Long.valueOf(1));
SearchCriteria<UsageJobVO> sc = createSearchCriteria();
sc.addAnd("endMillis", SearchCriteria.Op.EQ, Long.valueOf(0));

View File

@ -2257,6 +2257,11 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
}
}
if (_usageJobDao.getNextRecurringJob() == null) {
// Own the usage processing immediately if no other node is owning it
_usageJobDao.createNewJob(_hostname, _pid, UsageJobVO.JOB_TYPE_RECURRING);
}
Long jobId = _usageJobDao.checkHeartbeat(_hostname, _pid, _aggregationDuration);
if (jobId != null) {
// if I'm taking over the job...see how long it's been since the last job, and if it's more than the