add a retry.  this test is flaky on github.
package dev.morphia.test;
+import com.mongodb.MongoQueryException;
import com.mongodb.TransactionOptions;
import dev.morphia.experimental.MorphiaSession;
import dev.morphia.test.models.Rectangle;
@@ -88,6 +89,9 @@ public class TestTransactions extends TestBase {
@Test
public void manual() {
+ boolean success = false;
+ int count = 0;
+ while (!success && count < 5) {
try (MorphiaSession session = getDs().startSession()) {
session.startTransaction();
@@ -102,6 +106,16 @@ public class TestTransactions extends TestBase {
assertNotNull(session.find(User.class).first());
session.commitTransaction();
+ success = true;
+ } catch (MongoQueryException e) {
+ if (e.getErrorCode() == 251 && e.getErrorMessage().contains("has been aborted")) {
+ count++;
+ } else {
+ throw e;
+ }
+ } catch (RuntimeException e) {
+ throw e;
+ }
}
assertNotNull(getDs().find(Rectangle.class).first());
