Skip to content

Commit

Permalink
Bugfix: adjusted allocation SQL query to work for both PostgreSQL and…
Browse files Browse the repository at this point in the history
… MySQL
  • Loading branch information
eea03 committed Aug 19, 2015
1 parent bfd010d commit 3b63d45
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public List<ExecutionServer> getAllExecutionServers() {
@Transactional
public int allocateQueuedExecutionsForBackendByPriority(String backendID, int limit) {
final String queryStr = "UPDATE exec_pipeline SET backend_id = '%s'"
+ " WHERE id IN (SELECT e.id from exec_pipeline e WHERE e.backend_id IS NULL AND e.status = %d"
+ " ORDER BY e.order_number ASC, e.id ASC LIMIT %d FOR UPDATE)";
+ " WHERE id IN (SELECT id FROM"
+ " (SELECT e.id from exec_pipeline e WHERE e.backend_id IS NULL AND e.status = %d"
+ " ORDER BY e.order_number ASC, e.id ASC LIMIT %d FOR UPDATE) AS temp)";
String query = String.format(queryStr,
backendID,
0, // = QUEUED
Expand Down

0 comments on commit 3b63d45

Please sign in to comment.