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 2016/01/08 15:40:54 UTC
svn commit: r1723731 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
Author: reschke
Date: Fri Jan 8 14:40:54 2016
New Revision: 1723731
URL: http://svn.apache.org/viewvc?rev=1723731&view=rev
Log:
OAK-3852: RDBDocumentStore: batched append logic may loose property changes
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1723731&r1=1723730&r2=1723731&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Fri Jan 8 14:40:54 2016
@@ -697,8 +697,9 @@ public class RDBDocumentStore implements
new String[] { "id", "dsize", "deletedonce", "bdata", "data", "cmodcount", "modcount", "hasbinary", "modified" })));
// set of properties not serialized to JSON
- private static final Set<String> COLUMNPROPERTIES = new HashSet<String>(Arrays.asList(new String[] { ID,
- NodeDocument.HAS_BINARY_FLAG, NodeDocument.DELETED_ONCE, COLLISIONSMODCOUNT, MODIFIED, MODCOUNT }));
+ // when adding new columns also update UNHANDLEDPROPS!
+ private static final Set<String> COLUMNPROPERTIES = new HashSet<String>(Arrays.asList(
+ new String[] { ID, NodeDocument.HAS_BINARY_FLAG, NodeDocument.DELETED_ONCE, COLLISIONSMODCOUNT, MODIFIED, MODCOUNT }));
private final RDBDocumentSerializer ser = new RDBDocumentSerializer(this, COLUMNPROPERTIES);
@@ -1616,11 +1617,19 @@ public class RDBDocumentStore implements
}
}
+ // set of properties not serialized and not handled specifically by update code
+ private static final Set<Key> UNHANDLEDPROPS = new HashSet<Key>(
+ Arrays.asList(new Key[] { new Key(NodeDocument.HAS_BINARY_FLAG, null), new Key(NodeDocument.DELETED_ONCE, null) }));
+
/*
- * currently we use append for all updates, but this might change in the
- * future
+ * Detect update operations that contains changes to column properties not handled by the current appending code.
*/
private static boolean isAppendableUpdate(UpdateOp update) {
+ for (Key key : update.getChanges().keySet()) {
+ if (UNHANDLEDPROPS.contains(key)) {
+ return false;
+ }
+ }
return true;
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java?rev=1723731&r1=1723730&r2=1723731&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java Fri Jan 8 14:40:54 2016
@@ -443,6 +443,27 @@ public class BasicDocumentStoreTest exte
}
@Test
+ public void testModifyDeletedOnce() {
+ // https://issues.apache.org/jira/browse/OAK-2940
+ String id = this.getClass().getName() + ".testModifyDeletedOnce";
+ // create a test node
+ UpdateOp up = new UpdateOp(id, true);
+ up.set("_id", id);
+ up.set(NodeDocument.DELETED_ONCE, Boolean.FALSE);
+ boolean success = super.ds.create(Collection.NODES, Collections.singletonList(up));
+ assertTrue(success);
+ removeMe.add(id);
+
+ // update
+ up = new UpdateOp(id, false);
+ up.set("_id", id);
+ up.set(NodeDocument.DELETED_ONCE, Boolean.TRUE);
+ super.ds.update(Collection.NODES, Collections.singletonList(id), up);
+ NodeDocument nd = super.ds.find(Collection.NODES, id, 0);
+ assertEquals(((Boolean)nd.get(NodeDocument.DELETED_ONCE)).booleanValue(), Boolean.TRUE);
+ }
+
+ @Test
public void testInterestingStrings() {
// test case "gclef:\uD834\uDD1E" will fail on MySQL unless properly configured to use utf8mb4 charset // Assume.assumeTrue(!(super.dsname.equals("RDB-MySQL")));