keith-turner commented on code in PR #5728:
URL: https://github.com/apache/accumulo/pull/5728#discussion_r2195301372


##########
core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java:
##########
@@ -140,26 +168,16 @@ public long reserve() {
           events = statusChangeEvents;
         }
 
-        List<String> txdirs = new ArrayList<>(zk.getChildren(path));
-        Collections.sort(txdirs);
+        Queue<String> txdirs = getTxDirs();
 
-        synchronized (this) {
-          if (!txdirs.isEmpty() && txdirs.get(txdirs.size() - 
1).compareTo(lastReserved) <= 0) {
-            lastReserved = "";
+        while (true) {
+          String txdir = txdirs.poll();
+          if (txdir == null) {
+            break;
           }
-        }
-
-        for (String txdir : txdirs) {
           long tid = parseTid(txdir);
 
           synchronized (this) {
-            // this check makes reserve pick up where it left off, so that it 
cycles through all as
-            // it is repeatedly called.... failing to do so can lead to
-            // starvation where fate ops that sort higher and hold a lock are 
never reserved.
-            if (txdir.compareTo(lastReserved) <= 0) {

Review Comment:
   The queue avoids this skipping behavior, but still allows the thread to 
cycle through all fate ops when looking for work.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to