[
https://issues.apache.org/jira/browse/OAK-4939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15689085#comment-15689085
]
Chetan Mehrotra commented on OAK-4939:
--------------------------------------
Here is the groovy script used to "corrupt" the index on demand
{code}
import org.apache.jackrabbit.oak.api.Type
import org.apache.jackrabbit.oak.commons.PathUtils
import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates
import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry
import org.apache.jackrabbit.oak.spi.state.NodeBuilder
import org.apache.jackrabbit.oak.spi.state.NodeState
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils
import org.apache.jackrabbit.oak.spi.state.NodeStore
NodeStore ns = getStore()
String indexPath = "/oak:index/lucene/:data"
NodeState dir = NodeStateUtils.getNode(ns.root, indexPath)
def fileInfos = getFileInfos(dir)
fileInfos.each {println it}
//First entry would be segments.gen
//So touch second entry
String fileNameToCorrupt = fileInfos[1].name
println "Corrupting $fileNameToCorrupt"
NodeBuilder builder = ns.root.builder()
NodeBuilder file = childBuilder(builder, PathUtils.concat(indexPath,
fileNameToCorrupt))
file.setProperty(PropertyStates.createProperty("jcr:data",[new
ArrayBasedBlob("foo".getBytes())],Type.BINARIES))
ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY)
def getStore(){
osgi.getService(org.apache.sling.jcr.api.SlingRepository.class).manager.store
}
private List getFileInfos(NodeState dir) {
def fileInfos = []
dir.childNodeEntries.each { ChildNodeEntry e ->
fileInfos << [name: e.name, createdTime:
e.nodeState.getLong("jcr:lastModified")]
}
fileInfos.sort { -it.createdTime }
return fileInfos
}
NodeBuilder childBuilder(NodeBuilder root, String path){
NodeBuilder nb = root;
for (String nodeName : PathUtils.elements(path)){
nb = nb.child(nodeName);
}
return nb;
}
{code}
> Isolate corrupted index and make async indexer more resilient
> -------------------------------------------------------------
>
> Key: OAK-4939
> URL: https://issues.apache.org/jira/browse/OAK-4939
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: lucene, query
> Reporter: Chetan Mehrotra
> Assignee: Chetan Mehrotra
> Fix For: 1.6, 1.5.15
>
> Attachments: OAK-4939-v1.diff, OAK-4939-v2.diff,
> corrupt-index-mbean.png
>
>
> Currently if any one of the async index gets corrupted it brings down the
> whole async indexer and no other index gets updated untill system
> administrator reindexes the problamatic async index.
> Instead of fail all we should isolate such corrupted index and mark them as
> corrupted. And still let async indexer progress for other working indexes.
> This would ensure that one corrupted index does not affect the whole system
> and allow the application to work partially.
> Feature branch -
> https://github.com/chetanmeh/jackrabbit-oak/compare/trunk...chetanmeh:OAK-4939?expand=1
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)