Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -41,7 +41,11 @@ class ReferenceCheckArticleWorker
|
||||
}
|
||||
|
||||
// 先释放其它文章上的僵尸 RUNNING,避免全局串行永久堵死
|
||||
$this->recoverStaleForeignBatches($batchId);
|
||||
try {
|
||||
$this->recoverStaleForeignBatches($batchId);
|
||||
} catch (\Throwable $e) {
|
||||
$this->svc->log('ReferenceCheckArticleWorker recoverStaleForeignBatches err=' . $e->getMessage());
|
||||
}
|
||||
|
||||
if (!$this->canStartArticleWork($batchId)) {
|
||||
$this->svc->log('ReferenceCheckArticleWorker defer batch_id=' . $batchId . ' other article running');
|
||||
@@ -188,10 +192,12 @@ class ReferenceCheckArticleWorker
|
||||
{
|
||||
$exceptBatchId = intval($exceptBatchId);
|
||||
$staleBefore = date('Y-m-d H:i:s', time() - self::BATCH_STALE_SECONDS);
|
||||
// ThinkPHP 5:whereRaw 绑参会与命名占位符冲突(HY093),日期直接拼进 SQL
|
||||
$staleSql = "(updated_at IS NULL OR updated_at < '" . addslashes($staleBefore) . "')";
|
||||
$rows = Db::name('article_reference_relevance_check_batch')
|
||||
->where('batch_status', self::BATCH_RUNNING)
|
||||
->where('id', '<>', $exceptBatchId)
|
||||
->whereRaw('(updated_at IS NULL OR updated_at < ?)', [$staleBefore])
|
||||
->whereRaw($staleSql)
|
||||
->order('id asc')
|
||||
->limit(20)
|
||||
->select();
|
||||
@@ -206,7 +212,7 @@ class ReferenceCheckArticleWorker
|
||||
$affected = Db::name('article_reference_relevance_check_batch')
|
||||
->where('id', $bid)
|
||||
->where('batch_status', self::BATCH_RUNNING)
|
||||
->whereRaw('(updated_at IS NULL OR updated_at < ?)', [$staleBefore])
|
||||
->whereRaw($staleSql)
|
||||
->update([
|
||||
'batch_status' => self::BATCH_WAITING,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
|
||||
Reference in New Issue
Block a user