Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Http/Controllers/Backend/QsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function getBatches(Request $request): \Illuminate\Http\Response
['failed', '=', false]
])
->orderBy('id')
->lockForUpdate()
->first();

if ($oldestBatch === null) {
Expand Down
10 changes: 9 additions & 1 deletion app/Jobs/CreateQueryserviceBatchesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ private function getNewEntities(int $latestCheckpoint): array

private function tryToAppendEntitesToExistingBatches(array $entityIdsFromEvents, int $wikiId): bool
{
if (DB::transactionLevel() < 1) {
throw new \Exception(
'This method can only be run within the context of a transaction.'
);
}

$notDoneBatches = QsBatch::where([
['done', '=', 0],
['pending_since', '=', null],
['failed', '=', false],
['wiki_id', '=', $wikiId],
])->get();
])
->lockForUpdate()
Comment thread
m90 marked this conversation as resolved.
->get();

foreach ($notDoneBatches as $qsBatch) {
$entitiesOnBatch = explode(',', $qsBatch->entityIds);
Expand Down
1 change: 1 addition & 0 deletions app/Jobs/RequeuePendingQsBatchesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private function markBatchesFailed(): array
['done', '=', false]
])
->select('id')
->lockForUpdate()
->get()
->pluck('id')
->toArray();
Expand Down