package com.orientechnologies.orient.core.db;

public class OConnectionNext {
  private volatile int next = 0;
  private final int limit;

  public OConnectionNext(int limit) {
    this.limit = limit;
  }

  public synchronized int next() {
    if (next < limit) {
      next++;
    } else {
      next = 0;
    }
    return next;
  }
}

@@ -242,52 +242,38 @@
     
-if (next %3C limit) %7B%0A      next++;%0A    %7D else
+next++;%0A    if (next %3E= limit)
  %7B%0A 

make first round robing node select more reliable