You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by da...@apache.org on 2026/10/26 04:36:15 UTC

(jackrabbit-oak) 01/01: OAK-12481: align MongoDB requirements with supported drivers

This is an automated email from the ASF dual-hosted git repository.

rishabhdaim pushed a commit to branch OAK-12481
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 17fe917a0ef68a79b62d86f36fcec20bf745adc6
Author: rishabhdaim <ri...@gmail.com>
AuthorDate: Mon Oct 26 10:05:57 2026 +0530

    OAK-12481: align MongoDB requirements with supported drivers
---
 .../nodestore/document/mongo-document-store.md     | 15 +++++
 oak-parent/pom.xml                                 |  1 -
 .../oak/plugins/document/mongo/MongoStatus.java    |  5 +-
 .../plugins/document/mongo/MongoStatusTest.java    | 21 ------
 .../document/mongo/MongoStatusVersionTest.java     | 75 ++++++++++++++++++++++
 5 files changed, 93 insertions(+), 24 deletions(-)

diff --git a/oak-doc/src/site/markdown/nodestore/document/mongo-document-store.md b/oak-doc/src/site/markdown/nodestore/document/mongo-document-store.md
index 296df61682..6fdc110e2f 100644
--- a/oak-doc/src/site/markdown/nodestore/document/mongo-document-store.md
+++ b/oak-doc/src/site/markdown/nodestore/document/mongo-document-store.md
@@ -26,6 +26,20 @@ Before deploying a MongoDocumentStore on MongoDB, make sure recommendations
 described in [production notes](https://docs.mongodb.com/manual/administration/production-notes/)
 have been applied.
 
+Starting with Oak 2.10.0, the minimum MongoDB server version depends on the
+Java driver in use:
+
+Java driver | Minimum MongoDB server
+------------|-----------------------
+5.2 - 5.4 | 4.0
+5.5 | 4.2
+
+Upgrade MongoDB before switching to a driver that requires a newer server.
+
+For production, use a release covered by
+[MongoDB's support policy](https://www.mongodb.com/legal/support-policy/lifecycles).
+MongoDB 6.0 and earlier have reached end of life.
+
 The recommended MongoDB version depends on the Oak release. Below table lists
 the recommended MongoDB version for each Oak release. More recent MongoDB
 versions may also work, but are untested.
@@ -40,6 +54,7 @@ Oak Release | MongoDB version
 1.8.7 or newer | 3.6.x
 1.22.x or newer | 5.0.x
 1.62.0 or newer | 5.0 (soon 6.0)
+2.10.0 or newer | 8.0.x
 
 For production deployments use a replica-set with at least three mongod
 instances and a majority write concern. Fewer than three instances (e.g. two
diff --git a/oak-parent/pom.xml b/oak-parent/pom.xml
index dc19350aab..6beb7bbe1d 100644
--- a/oak-parent/pom.xml
+++ b/oak-parent/pom.xml
@@ -55,7 +55,6 @@
     <mongo.db>MongoMKDB</mongo.db>
     <mongo.db2>MongoMKDB2</mongo.db2>
     <mongo.url />
-    <mongo.version>3.6</mongo.version>
     <segment.db>SegmentMK</segment.db>
     <lucene.version>4.7.2</lucene.version>
     <mongo.driver.version>5.4.0</mongo.driver.version>
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatus.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatus.java
index 452696babe..3026c8461f 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatus.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatus.java
@@ -72,8 +72,9 @@ public class MongoStatus implements ServerMonitorListener {
     }
 
     public void checkVersion() {
-        if (!isVersion(2, 6)) {
-            String msg = "MongoDB version 2.6.0 or higher required. " +
+        // Match the oldest supported driver; newer drivers enforce their own minimum.
+        if (!isVersion(4, 0)) {
+            String msg = "MongoDB version 4.0.0 or higher required. " +
                     "Currently connected to a MongoDB with version: " + version;
             throw new RuntimeException(msg);
         }
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusTest.java
index d34a471473..b12ca2bd7b 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusTest.java
@@ -47,7 +47,6 @@ import static org.apache.jackrabbit.oak.plugins.document.MongoUtils.isAvailable;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeTrue;
 
 public class MongoStatusTest {
@@ -109,26 +108,6 @@ public class MongoStatusTest {
         assertTrue(status.getVersion().matches("^\\d+\\.\\d+\\.\\d+$"));
     }
 
-    @Test
-    public void testCheckVersionValid() {
-        for (String v : new String[] { "2.6.0", "2.7.0", "3.0.0"}) {
-            status.setVersion(v);
-            status.checkVersion();
-        }
-    }
-
-    @Test
-    public void testCheckVersionInvalid() {
-        for (String v : new String[] { "1.0.0", "2.0.0", "2.5.0"}) {
-            status.setVersion(v);
-            try {
-                status.checkVersion();
-                fail("Version " + v + " shouldn't be allowed");
-            } catch (Exception e) {
-            }
-        }
-    }
-
     @Test
     public void unauthorized() {
         MongoTestClient testClient = new MongoTestClient(MongoUtils.URL) {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusVersionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusVersionTest.java
new file mode 100644
index 0000000000..02dd16731c
--- /dev/null
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoStatusVersionTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.document.mongo;
+
+import com.mongodb.client.MongoClient;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+/**
+ * Tests the minimum server version enforced by {@link MongoStatus} without MongoDB.
+ */
+public class MongoStatusVersionTest {
+
+    private final MongoClient client = Mockito.mock(MongoClient.class);
+    private final MongoStatus status = new MongoStatus(client, "test");
+
+    /**
+     * Version checks use the supplied version without contacting MongoDB.
+     */
+    @After
+    public void verifyNoDatabaseAccess() {
+        Mockito.verifyNoInteractions(client);
+    }
+
+    /**
+     * The first supported server release is accepted.
+     */
+    @Test
+    public void acceptsMinimumVersion() {
+        status.setVersion("4.0.0");
+        status.checkVersion();
+    }
+
+    /**
+     * Patch releases and newer server generations remain supported.
+     */
+    @Test
+    public void acceptsNewerVersions() {
+        for (String version : new String[] {"4.0.28", "4.2.0", "4.2.24", "4.4.0", "5.0.0", "8.0.0"}) {
+            status.setVersion(version);
+            status.checkVersion();
+        }
+    }
+
+    /**
+     * Older servers are rejected with the required and actual versions.
+     */
+    @Test
+    public void rejectsUnsupportedVersions() {
+        for (String version : new String[] {"3.6.23", "3.9.99", "2.6.0", "2.5.0", "2.0.0", "1.0.0"}) {
+            status.setVersion(version);
+            RuntimeException exception = Assert.assertThrows("Version " + version,
+                    RuntimeException.class, status::checkVersion);
+            Assert.assertEquals("MongoDB version 4.0.0 or higher required. "
+                    + "Currently connected to a MongoDB with version: " + version,
+                    exception.getMessage());
+        }
+    }
+}