Author: reschke
Date: Tue Jun 28 14:00:21 2016
New Revision: 1750512
URL: http://svn.apache.org/viewvc?rev=1750512&view=rev
Log:
OAK-4494: Stale documents after revision GC in cluster (ported to 1.4)
Fixes specific to RDBDocumentStore.
Modified:
jackrabbit/oak/branches/1.4/ (props changed)
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
Propchange: jackrabbit/oak/branches/1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 28 14:00:21 2016
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738775,1738795,1738833,1738950,1738957,1738963,1739894,1740116,1740625-1740626,1740971,1741032,1741339,1741343,1742520,1742888,1742916,1743097,1743172,1743343,1744265,1744959,1745038,1745197,1745368,1746086,1746117,1746342,1746345,1746696,1746981,1747341-1747342,1747492,1747512,1748505,1748553,1748870,1749275,1749350,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750076-1750077,1750287,1750457,1750465
+/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738775,1738795,1738833,1738950,1738957,1738963,1739894,1740116,1740625-1740626,1740971,1741032,1741339,1741343,1742520,1742888,1742916,1743097,1743172,1743343,1744265,1744959,1745038,1745197,1745368,1746086,1746117,1746342,1746345,1746696,1746981,1747341-1747342,1747492,1747512,1748505,1748553,1748870,1749275,1749350,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750076-1750077,1750287,1750457,1750465,1750495
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java?rev=1750512&r1=1750511&r2=1750512&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
Tue Jun 28 14:00:21 2016
@@ -146,7 +146,9 @@ public class RDBDocumentSerializer {
public <T extends Document> T fromRow(@Nonnull Collection<T> collection,
@Nonnull RDBRow row) throws DocumentStoreException {
T doc = collection.newDocument(store);
doc.put(ID, row.getId());
- doc.put(MODIFIED, row.getModified());
+ if (row.getModified() != 0) {
+ doc.put(MODIFIED, row.getModified());
+ }
doc.put(MODCOUNT, row.getModcount());
if (RDBDocumentStore.USECMODCOUNT) {
doc.put(CMODCOUNT, row.getCollisionsModcount());
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1750512&r1=1750511&r2=1750512&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Tue Jun 28 14:00:21 2016
@@ -1524,9 +1524,10 @@ public class RDBDocumentStore implements
final Stopwatch watch = startWatch();
boolean docFound = true;
try {
- long lastmodcount = -1;
+ long lastmodcount = -1, lastmodified = -1;
if (cachedDoc != null) {
lastmodcount = modcountOf(cachedDoc);
+ lastmodified = modifiedOf(cachedDoc);
}
connection = this.ch.getROConnection();
RDBRow row = db.read(connection, tmd, id, lastmodcount);
@@ -1535,11 +1536,18 @@ public class RDBDocumentStore implements
docFound = false;
return null;
} else {
- if (lastmodcount == row.getModcount()) {
+ if (lastmodcount == row.getModcount() && lastmodified ==
row.getModified() && lastmodified >= 1) {
// we can re-use the cached document
cachedDoc.markUpToDate(System.currentTimeMillis());
return castAsT(cachedDoc);
} else {
+ // workaround: need to re-read if data is not present
+ // that would be the case if the modcount did match but
the modified time did not
+ // see OAK-4509
+ if (row.getData() == null) {
+ row = db.read(connection, tmd, id, -1);
+ connection.commit();
+ }
return convertFromDBObject(collection, row);
}
}
@@ -1865,6 +1873,11 @@ public class RDBDocumentStore implements
return n != null ? n : -1;
}
+ private static long modifiedOf(@Nonnull Document doc) {
+ Object l = doc.get(NodeDocument.MODIFIED_IN_SECS);
+ return (l instanceof Long) ? ((Long)l).longValue() : -1;
+ }
+
@Nonnull
protected <T extends Document> T convertFromDBObject(@Nonnull
Collection<T> collection, @Nonnull RDBRow row) {
// this method is present here in order to facilitate unit testing for
OAK-3566
@@ -1890,18 +1903,21 @@ public class RDBDocumentStore implements
if (cachedModCount == null) {
throw new IllegalStateException("Missing " +
Document.MOD_COUNT);
}
- if (modCount <= cachedModCount) {
- // we can use the cached document
- Lock lock = locks.acquire(row.getId());
- try {
- if (qp.mayUpdate(id)) {
- inCache.markUpToDate(now);
+ long lastmodified = modifiedOf(inCache);
+ if (lastmodified == row.getModified() && lastmodified >= 1) {
+ if (modCount <= cachedModCount) {
+ // we can use the cached document
+ Lock lock = locks.acquire(row.getId());
+ try {
+ if (qp.mayUpdate(id)) {
+ inCache.markUpToDate(now);
+ }
}
+ finally {
+ lock.unlock();
+ }
+ return castAsT(inCache);
}
- finally {
- lock.unlock();
- }
- return castAsT(inCache);
}
}
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java?rev=1750512&r1=1750511&r2=1750512&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/ResurrectNodeAfterRevisionGCTest.java
Tue Jun 28 14:00:21 2016
@@ -38,7 +38,6 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeFalse;
public class ResurrectNodeAfterRevisionGCTest
extends AbstractMultiDocumentStoreTest {
@@ -49,7 +48,6 @@ public class ResurrectNodeAfterRevisionG
public ResurrectNodeAfterRevisionGCTest(DocumentStoreFixture dsf) {
super(dsf);
- assumeFalse(dsf instanceof DocumentStoreFixture.RDBFixture);
}
@Before