Browse Source

Merge pull request #691 in CORE/base-third from release/10.0 to bugfix/10.0

* commit '8ef2f5133d9c87dff8735ac4ea8c720eb77239c6':
  DEC-14382 修改方法名
  DEC-14382 修改相关sql以及逻辑优化BI定时任务延迟现象
bugfix/10.0
superman 4 years ago
parent
commit
b1379b9e6c
  1. 2
      fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/DriverDelegate.java
  2. 28
      fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java
  3. 4
      fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCConstants.java
  4. 4
      fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java

2
fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/DriverDelegate.java

@ -972,7 +972,7 @@ public interface DriverDelegate {
public List<TriggerKey> selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount) public List<TriggerKey> selectTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount)
throws SQLException; throws SQLException;
List<TriggerKey> selectAppointTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId); List<TriggerKey> selectAppointOrNonTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId);
/** /**
* <p> * <p>

28
fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/JobStoreSupport.java

@ -673,11 +673,11 @@ public abstract class JobStoreSupport implements JobStore, Constants {
this.schedSignaler = signaler; this.schedSignaler = signaler;
// If the user hasn't specified an explicit lock handler, then // If the user hasn't specified an explicit lock handler, then
// choose one based on CMT/Clustered/UseDBLocks. // choose one based on CMT/Clustered/UseDBLocks.
if (getLockHandler() == null) { if (getLockHandler() == null) {
// If the user hasn't specified an explicit lock handler, // If the user hasn't specified an explicit lock handler,
// then we *must* use DB locks with clustering // then we *must* use DB locks with clustering
if (isClustered()) { if (isClustered()) {
setUseDBLocks(true); setUseDBLocks(true);
@ -987,8 +987,8 @@ public abstract class JobStoreSupport implements JobStore, Constants {
List<TriggerKey> misfiredTriggers = new LinkedList<TriggerKey>(); List<TriggerKey> misfiredTriggers = new LinkedList<TriggerKey>();
long earliestNewTime = Long.MAX_VALUE; long earliestNewTime = Long.MAX_VALUE;
// We must still look for the MISFIRED state in case triggers were left // We must still look for the MISFIRED state in case triggers were left
// in this state when upgrading to this version that does not support it. // in this state when upgrading to this version that does not support it.
boolean hasMoreMisfiredTriggers = boolean hasMoreMisfiredTriggers =
getDelegate().hasMisfiredTriggersInState( getDelegate().hasMisfiredTriggersInState(
conn, STATE_WAITING, getMisfireTime(), conn, STATE_WAITING, getMisfireTime(),
@ -2835,12 +2835,10 @@ public abstract class JobStoreSupport implements JobStore, Constants {
currentLoopCount++; currentLoopCount++;
try { try {
long misfireTime = getMisfireTime(); long misfireTime = getMisfireTime();
List<TriggerKey> waitingKeys = getDelegate().selectTriggerToAcquire(conn, noLaterThan + timeWindow, misfireTime, maxCount); List<TriggerKey> appointKeys = getDelegate().selectAppointOrNonTriggerToAcquire(conn, noLaterThan + timeWindow, misfireTime, maxCount, this.currentId);
List<TriggerKey> appointKeys = getDelegate().selectAppointTriggerToAcquire(conn, noLaterThan + timeWindow, misfireTime, maxCount, this.currentId);
List<TriggerKey> allKeys = new ArrayList<TriggerKey>(); List<TriggerKey> allKeys = new ArrayList<TriggerKey>();
Set<String> keyIds = new HashSet<String>(); Set<String> keyIds = new HashSet<String>();
mergeKeys(allKeys, keyIds, waitingKeys);
mergeKeys(allKeys, keyIds, appointKeys); mergeKeys(allKeys, keyIds, appointKeys);
// No trigger is ready to fire yet. // No trigger is ready to fire yet.
@ -3117,7 +3115,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
try { try {
if (triggerInstCode == CompletedExecutionInstruction.DELETE_TRIGGER) { if (triggerInstCode == CompletedExecutionInstruction.DELETE_TRIGGER) {
if (trigger.getNextFireTime() == null) { if (trigger.getNextFireTime() == null) {
// double check for possible reschedule within job // double check for possible reschedule within job
// execution, which would cancel the need to delete... // execution, which would cancel the need to delete...
TriggerStatus stat = getDelegate().selectTriggerStatus( TriggerStatus stat = getDelegate().selectTriggerStatus(
conn, trigger.getKey()); conn, trigger.getKey());
@ -3236,7 +3234,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
try { try {
RecoverMisfiredJobsResult result = RecoverMisfiredJobsResult.NO_OP; RecoverMisfiredJobsResult result = RecoverMisfiredJobsResult.NO_OP;
// Before we make the potentially expensive call to acquire the // Before we make the potentially expensive call to acquire the
// trigger lock, peek ahead to see if it is likely we would find // trigger lock, peek ahead to see if it is likely we would find
// misfired triggers requiring recovery. // misfired triggers requiring recovery.
int misfireCount = (getDoubleCheckLockMisfireHandler()) ? int misfireCount = (getDoubleCheckLockMisfireHandler()) ?
@ -3311,8 +3309,8 @@ public abstract class JobStoreSupport implements JobStore, Constants {
Connection conn = getNonManagedTXConnection(); Connection conn = getNonManagedTXConnection();
try { try {
// Other than the first time, always checkin first to make sure there is // Other than the first time, always checkin first to make sure there is
// work to be done before we acquire the lock (since that is expensive, // work to be done before we acquire the lock (since that is expensive,
// and is almost never necessary). This must be done in a separate // and is almost never necessary). This must be done in a separate
// transaction to prevent a deadlock under recovery conditions. // transaction to prevent a deadlock under recovery conditions.
List<SchedulerStateRecord> failedRecords = null; List<SchedulerStateRecord> failedRecords = null;
@ -3325,7 +3323,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
getLockHandler().obtainLock(conn, LOCK_STATE_ACCESS); getLockHandler().obtainLock(conn, LOCK_STATE_ACCESS);
transStateOwner = true; transStateOwner = true;
// Now that we own the lock, make sure we still have work to do. // Now that we own the lock, make sure we still have work to do.
// The first time through, we also need to make sure we update/create our state record // The first time through, we also need to make sure we update/create our state record
failedRecords = (firstCheckIn) ? clusterCheckIn(conn) : findFailedInstances(conn); failedRecords = (firstCheckIn) ? clusterCheckIn(conn) : findFailedInstances(conn);
@ -3838,7 +3836,7 @@ public abstract class JobStoreSupport implements JobStore, Constants {
Connection conn = null; Connection conn = null;
try { try {
if (lockName != null) { if (lockName != null) {
// If we aren't using db locks, then delay getting DB connection // If we aren't using db locks, then delay getting DB connection
// until after acquiring the lock since it isn't needed. // until after acquiring the lock since it isn't needed.
if (getLockHandler().requiresConnection()) { if (getLockHandler().requiresConnection()) {
conn = getNonManagedTXConnection(); conn = getNonManagedTXConnection();
@ -4047,6 +4045,4 @@ public abstract class JobStoreSupport implements JobStore, Constants {
} }
} }
} }
} }
// EOF

4
fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCConstants.java

@ -541,12 +541,12 @@ public interface StdJDBCConstants extends Constants {
+ "AND (" + COL_MISFIRE_INSTRUCTION + " = -1 OR (" + COL_MISFIRE_INSTRUCTION + " != -1 AND " + COL_NEXT_FIRE_TIME + " >= ?)) " + "AND (" + COL_MISFIRE_INSTRUCTION + " = -1 OR (" + COL_MISFIRE_INSTRUCTION + " != -1 AND " + COL_NEXT_FIRE_TIME + " >= ?)) "
+ "ORDER BY " + COL_NEXT_FIRE_TIME + " ASC, " + COL_PRIORITY + " DESC"; + "ORDER BY " + COL_NEXT_FIRE_TIME + " ASC, " + COL_PRIORITY + " DESC";
String SELECT_NEXT_APPOINT_TRIGGER_TO_ACQUIRE = "SELECT " String SELECT_NEXT_APPOINT_OR_NON_TRIGGER_TO_ACQUIRE = "SELECT "
+ COL_TRIGGER_NAME + ", " + COL_TRIGGER_GROUP + ", " + COL_TRIGGER_NAME + ", " + COL_TRIGGER_GROUP + ", "
+ COL_NEXT_FIRE_TIME + ", " + COL_PRIORITY + " FROM " + COL_NEXT_FIRE_TIME + ", " + COL_PRIORITY + " FROM "
+ TABLE_PREFIX_SUBST + TABLE_TRIGGERS + " WHERE " + TABLE_PREFIX_SUBST + TABLE_TRIGGERS + " WHERE "
+ COL_SCHEDULER_NAME + " = " + SCHED_NAME_SUBST + COL_SCHEDULER_NAME + " = " + SCHED_NAME_SUBST
+ " AND " + COL_APPOINT_ID + " = ?" + " AND (" + COL_APPOINT_ID + " = ? OR "+ COL_APPOINT_ID + " IS NULL)"
+ " AND " + COL_TRIGGER_STATE + " = ? AND " + COL_NEXT_FIRE_TIME + " <= ? " + " AND " + COL_TRIGGER_STATE + " = ? AND " + COL_NEXT_FIRE_TIME + " <= ? "
+ "AND (" + COL_MISFIRE_INSTRUCTION + " = -1 OR (" + COL_MISFIRE_INSTRUCTION + " != -1 AND " + COL_NEXT_FIRE_TIME + " >= ?)) " + "AND (" + COL_MISFIRE_INSTRUCTION + " = -1 OR (" + COL_MISFIRE_INSTRUCTION + " != -1 AND " + COL_NEXT_FIRE_TIME + " >= ?)) "
+ "ORDER BY " + COL_NEXT_FIRE_TIME + " ASC, " + COL_PRIORITY + " DESC"; + "ORDER BY " + COL_NEXT_FIRE_TIME + " ASC, " + COL_PRIORITY + " DESC";

4
fine-quartz/src/main/java/com/fr/third/v2/org/quartz/impl/jdbcjobstore/StdJDBCDelegate.java

@ -2656,12 +2656,12 @@ public class StdJDBCDelegate implements DriverDelegate, StdJDBCConstants {
} }
} }
public List<TriggerKey> selectAppointTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId) { public List<TriggerKey> selectAppointOrNonTriggerToAcquire(Connection conn, long noLaterThan, long noEarlierThan, int maxCount, String appointId) {
PreparedStatement ps = null; PreparedStatement ps = null;
ResultSet rs = null; ResultSet rs = null;
List<TriggerKey> nextTriggers = new LinkedList<TriggerKey>(); List<TriggerKey> nextTriggers = new LinkedList<TriggerKey>();
try { try {
ps = conn.prepareStatement(rtp(SELECT_NEXT_APPOINT_TRIGGER_TO_ACQUIRE)); ps = conn.prepareStatement(rtp(SELECT_NEXT_APPOINT_OR_NON_TRIGGER_TO_ACQUIRE));
if (maxCount < 1) if (maxCount < 1)
maxCount = 1; maxCount = 1;

Loading…
Cancel
Save