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 re...@apache.org on 2026/05/06 06:31:45 UTC

(jackrabbit-oak) branch trunk updated: OAK-12187: MongoDocumentStore: improve diagnostics for too large docs in findAndModify (#2885)

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

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


The following commit(s) were added to refs/heads/trunk by this push:
     new 5056b724bd OAK-12187: MongoDocumentStore: improve diagnostics for too large docs in findAndModify (#2885)
5056b724bd is described below

commit 5056b724bd56f7786f406bc77d0f6339dd9c160e
Author: Julian Reschke <re...@apache.org>
AuthorDate: Wed May 6 08:31:39 2026 +0200

    OAK-12187: MongoDocumentStore: improve diagnostics for too large docs in findAndModify (#2885)
---
 .../plugins/document/mongo/MongoDocumentStore.java |  4 +++
 .../document/mongo/MongoDBExceptionTest.java       | 36 ++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
index ba1afcb9c7..a683938213 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
@@ -1159,6 +1159,10 @@ public class MongoDocumentStore implements DocumentStore {
             LOG.error("Failed to update the document with id={} with MongoCommandException message = '{}'.",
                     updateOp.getId(), e.getMessage());
             throw handleException(e, collection, updateOp.getId());
+        } catch (BSONException e) {
+            LOG.error("Failed to update the document with id={} with BSONException message = '{}'.",
+                    updateOp.getId(), e.getMessage());
+            throw handleException(e, collection, updateOp.getId());
         } catch (Exception e) {
             throw handleException(e, collection, updateOp.getId());
         } finally {
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
index b0d3e0ac4b..7824568631 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
+++ b/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java
@@ -239,6 +239,42 @@ public class MongoDBExceptionTest {
         }
     }
 
+    @Test
+    public void findAndModifyLarge() {
+        // check that exceptions for large request payloads get logged
+
+        LogCustomizer customizer = LogCustomizer.forLogger(MongoDocumentStore.class.getName()).create();
+        customizer.starting();
+
+        String docName = "/foogrowingdoc";
+        int i = 0;
+
+        StringBuilder pvalue = new StringBuilder();
+
+        store.createOrUpdate(Collection.NODES, new UpdateOp(docName,true));
+        UpdateOp setprop = new UpdateOp(docName, true);
+        setprop.set("long", pvalue.toString());
+        store.findAndUpdate(Collection.NODES, setprop);
+
+        try {
+            for (i = 0; i < 32; i++) {
+                pvalue.append(create1MBContentLotsNonASCII());
+            }
+            UpdateOp updateOp = new UpdateOp(docName, true);
+            updateOp.set("long", pvalue.toString());
+            store.findAndUpdate(Collection.NODES, updateOp);
+            fail("should not get here");
+        } catch (DocumentStoreException dseExpected) {
+            assertTrue("exception cause should be instance of " + BSONException.class.getName(),
+                    dseExpected.getCause() instanceof BSONException);
+            String log = customizer.getLogs().toString();
+            assertTrue("Should contain id /foogrowingdoc, got: " + log, log.contains("/foogrowingdoc"));
+        } finally {
+            customizer.finished();
+        }
+
+    }
+
     @Test
     public void multiCreateOrUpdate16MBDoc() {