Add "ORDER BY" to top of lock queue checks 31/78131/4
authorMohammad Salehe <salehe@cs.toronto.edu>
Fri, 8 Feb 2019 16:23:33 +0000 (11:23 -0500)
committerMohammad Salehe <salehe@cs.toronto.edu>
Mon, 25 Feb 2019 03:23:39 +0000 (22:23 -0500)
Add explicit "ORDER BY" to top of lock queue check queries

Change-Id: Ibb985d21283cd952e609b8fbb8d78194f5891d60
Issue-ID: MUSIC-148
Signed-off-by: Mohammad Salehe <salehe@cs.toronto.edu>
src/main/java/org/onap/music/lockingservice/cassandra/CassaLockStore.java

index cbc172d..6e0b61a 100644 (file)
@@ -214,7 +214,7 @@ public class CassaLockStore {
                        logger.info(EELFLoggerDelegate.applicationLogger,
                                        "Peek in lock table for " +  keyspace+"."+table+"."+key);
                table = table_prepend_name+table; 
-                       String selectQuery = "select * from "+keyspace+"."+table+" where key='"+key+"' LIMIT 1;";
+                       String selectQuery = "SELECT * FROM "+keyspace+"."+table+" WHERE key='"+key+"' ORDER BY lockReference ASC LIMIT 1;";
                        PreparedQueryObject queryObject = new PreparedQueryObject();
                        queryObject.appendQueryString(selectQuery);
                        ResultSet results = dsHandle.executeOneConsistencyGet(queryObject);
@@ -238,7 +238,7 @@ public class CassaLockStore {
                 "Checking in lock table for " + keyspace + "." + table + "." + key);
         table = table_prepend_name + table;
         String selectQuery =
-                "select * from " + keyspace + "." + table + " where key='" + key + "';";
+                "SELECT * FROM " + keyspace + "." + table + " WHERE key='" + key + "' ORDER BY lockReference ASC;";
         PreparedQueryObject queryObject = new PreparedQueryObject();
         queryObject.appendQueryString(selectQuery);
         ResultSet rs = dsHandle.executeOneConsistencyGet(queryObject);