stefan-egli commented on code in PR #863:
URL: https://github.com/apache/jackrabbit-oak/pull/863#discussion_r1196611070
##########
oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java:
##########
@@ -157,6 +161,10 @@ public class MongoDocumentStore implements DocumentStore {
*/
public static final long DEFAULT_THROTTLING_TIME_MS =
Long.getLong("oak.mongo.throttlingTime", 20);
+ /**
+ * Document size of 16MB is a limit in Mongo
+ */
+ private static final long SIZE_LIMIT = 16777216;
Review Comment:
This one still seems open
##########
oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDBExceptionTest.java:
##########
@@ -132,8 +136,132 @@ public void idInExceptionMessage() {
}
}
+ @Test
+ public void createOrUpdate16MBDoc() {
+
+ UpdateOp updateOp = new UpdateOp("/foo", true);
+ updateOp = create16MBProp(updateOp);
+ exceptionMsg = "Document to upsert is larger than 16777216";
+ try {
+ store.createOrUpdate(Collection.NODES, updateOp);
+ fail("DocumentStoreException expected");
+ } catch (DocumentStoreException e) {
+ assertThat(e.getMessage(), containsString(exceptionMsg));
+ }
+ }
+
+ @Test
+ public void update16MBDoc() {
+
+ String docName = "/foo";
+ UpdateOp updateOp = new UpdateOp(docName, true);
+ updateOp = create1MBProp(updateOp);
+ store.createOrUpdate(Collection.NODES, updateOp);
+ updateOp = create16MBProp(updateOp);
+ exceptionMsg = "Resulting document after update is larger than
16777216";
+ try {
+ store.createOrUpdate(Collection.NODES, updateOp);
+ fail("DocumentStoreException expected");
+ } catch (DocumentStoreException e) {
+ assertThat(e.getMessage(), containsString(exceptionMsg));
+ assertThat(e.getMessage(), containsString(docName));
+ }
+ }
+
+ @Test
+ public void multiCreateOrUpdate16MBDoc() {
+
+ List<UpdateOp> updateOps = new ArrayList<>();
+
+ UpdateOp op = new UpdateOp("/test", true);
+ op = create1MBProp(op);
+
+ store.createOrUpdate(Collection.NODES, op);
+
+ UpdateOp op1 = new UpdateOp("/foo", true);
+ op1 = create16MBProp(op1);
+
+ // Updating both doc with 16MB
+ op = create16MBProp(op);
+ updateOps.add(op);
+ updateOps.add(op1);
+ exceptionMsg = "Resulting document after update is larger than
16777216";
+
+ try {
+ store.createOrUpdate(Collection.NODES, updateOps);
+ fail("DocumentStoreException expected");
+ } catch (DocumentStoreException e) {
+ assertThat(e.getMessage(), containsString(exceptionMsg));
+ }
+ }
+
+ @Test
+ public void create16MBDoc() {
+
+ List<UpdateOp> updateOps = new ArrayList<>();
+
+ UpdateOp op1 = new UpdateOp("/test", true);
+ op1 = create1MBProp(op1);
+
+ UpdateOp op2 = new UpdateOp("/foo", false);
+ op2 = create1MBProp(op2);
+ op2 = create16MBProp(op2);
+
+ updateOps.add(op1);
+ updateOps.add(op2);
+ String id = op2.getId();
+ exceptionMsg = "Payload document size is larger than maximum of
16777216.";
+ try {
+ store.create(Collection.NODES, updateOps);
+ fail("DocumentStoreException expected");
+ } catch (DocumentStoreException e) {
+ assertThat(e.getMessage(), containsString(exceptionMsg));
+ }
+ }
+
+ @Test
+ public void findAndUpdate16MBDoc() throws Exception {
+ UpdateOp op = new UpdateOp("/foo", true);
+ op = create1MBProp(op);
+ store.createOrUpdate(Collection.NODES, op);
+ op = create16MBProp(op);
+ exceptionMsg = "Resulting document after update is larger than
16777216";
+ try {
+ store.findAndUpdate(Collection.NODES, op);
+ fail("DocumentStoreException expected");
+ } catch (DocumentStoreException e) {
+ assertThat(e.getMessage(), containsString(exceptionMsg));
+ }
+ }
+
private void setExceptionMsg() {
client.setExceptionBeforeUpdate(exceptionMsg);
client.setExceptionBeforeQuery(exceptionMsg);
}
+
+ private UpdateOp create1MBProp(UpdateOp op) {
+ // create a 1 MB property
+ String content = create1MBContent();
+ op.set("property0", content);
+ return op;
+ }
+
+ private UpdateOp create16MBProp(UpdateOp op) {
+ // create a 1 MB property
+ String content = create1MBContent();
+ op.set("property0", content);
+
+ //create 16MB property
+ for (int i = 1; i < 16; i++) {
+ op.set("property"+ i, content);
+ }
Review Comment:
IIUC then this one is still open
--
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]