ankitaagar commented on code in PR #863:
URL: https://github.com/apache/jackrabbit-oak/pull/863#discussion_r1187174936


##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java:
##########
@@ -1470,8 +1487,18 @@ public <T extends Document> boolean create(Collection<T> 
collection, List<Update
                 }
                 insertSuccess = true;
                 return true;
-            } catch (MongoException e) {
-                return false;
+            } catch (BsonMaximumSizeExceededException e) {
+                T doct = null;
+                for (T doc : docs) {
+                    doct = doc;
+                    // doc.getMemory()/2 - converting from UTF-16 to UTF-8
+                    if (doc.getMemory()/2 > SIZE_LIMIT) {

Review Comment:
   I understand UTF-16 -> UTF-8 does not necessarily imply 50% reduction.
   We decided to show the error message.
   Let's say, I change it to 
   ```
   catch (BsonMaximumSizeExceededException e) {
                   LOG.error("Failed to create one of the documents from the 
below list " +
                           " with BsonMaximumSizeExceededException message = 
'{}'.", e.getMessage());
                   for (T doc : docs) {
                       LOG.error("Document ID {} and Size {} ",doc.getId(), 
doc.getMemory());
                   }
                   return false;
   }
   ```
   The log.error would look like:
   ```
   13:01:03.511 ERROR [main] MongoDocumentStore.java:1494      Failed to create 
one of the documents from the below list with BsonMaximumSizeExceededException 
message = 'Payload document size is larger than maximum of 16777216.'.
   13:01:03.511 ERROR [main] MongoDocumentStore.java:1494      Document ID 
/test and Size 2097764 
   13:01:03.511 ERROR [main] MongoDocumentStore.java:1494      Document ID /foo 
and Size 33557724 
   ```
   
   The exception message from Mongo shows the size limit as 16777216 and we are 
calculating it with doc.getMemory(). So a document with size 16778862 will show 
33557724 with doc.getMemory().
   
   Should I also log that BSON size is calculated in UTF-8 and we are doing it 
in UTF-16?
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to