mirror of https://github.com/apache/lucene.git
SOLR-4605: Rollback does not work correctly.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1457784 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
edbad37b0c
commit
d5bcb41586
|
@ -123,4 +123,8 @@ public final class TrackingDirectoryWrapper extends Directory implements Closeab
|
||||||
public Set<String> getCreatedFiles() {
|
public Set<String> getCreatedFiles() {
|
||||||
return createdFileNames;
|
return createdFileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Directory getDelegate() {
|
||||||
|
return other;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,8 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-4604: UpdateLog#init is over called on SolrCore#reload. (Mark Miller)
|
* SOLR-4604: UpdateLog#init is over called on SolrCore#reload. (Mark Miller)
|
||||||
|
|
||||||
|
* SOLR-4605: Rollback does not work correctly. (Mark S, Mark Miller)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void rollbackIndexWriter(SolrCore core) throws IOException {
|
public synchronized void rollbackIndexWriter(SolrCore core) throws IOException {
|
||||||
newIndexWriter(core, true, true);
|
newIndexWriter(core, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SolrIndexWriter createMainIndexWriter(SolrCore core, String name, boolean forceNewDirectory) throws IOException {
|
protected SolrIndexWriter createMainIndexWriter(SolrCore core, String name, boolean forceNewDirectory) throws IOException {
|
||||||
|
|
|
@ -250,6 +250,9 @@ public class BasicFunctionalityTest extends SolrTestCaseJ4 {
|
||||||
assertQ(req("id:[100 TO 110]")
|
assertQ(req("id:[100 TO 110]")
|
||||||
,"//*[@numFound='0']"
|
,"//*[@numFound='0']"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
assertU(h.simpleTag("rollback"));
|
||||||
|
assertU(commit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
|
import org.apache.lucene.store.NRTCachingDirectory;
|
||||||
|
import org.apache.lucene.store.RateLimitedDirectoryWrapper;
|
||||||
|
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +35,13 @@ public class MockDirectoryFactory extends EphemeralDirectoryFactory {
|
||||||
@Override
|
@Override
|
||||||
protected Directory create(String path, DirContext dirContext) throws IOException {
|
protected Directory create(String path, DirContext dirContext) throws IOException {
|
||||||
Directory dir = LuceneTestCase.newDirectory();
|
Directory dir = LuceneTestCase.newDirectory();
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
|
||||||
MockDirectoryWrapper mockDirWrapper = (MockDirectoryWrapper) dir;
|
Directory cdir = reduce(dir);
|
||||||
|
cdir = reduce(cdir);
|
||||||
|
cdir = reduce(cdir);
|
||||||
|
|
||||||
|
if (cdir instanceof MockDirectoryWrapper) {
|
||||||
|
MockDirectoryWrapper mockDirWrapper = (MockDirectoryWrapper) cdir;
|
||||||
|
|
||||||
// we can't currently do this check because of how
|
// we can't currently do this check because of how
|
||||||
// Solr has to reboot a new Directory sometimes when replicating
|
// Solr has to reboot a new Directory sometimes when replicating
|
||||||
|
@ -56,6 +64,20 @@ public class MockDirectoryFactory extends EphemeralDirectoryFactory {
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Directory reduce(Directory dir) {
|
||||||
|
Directory cdir = dir;
|
||||||
|
if (dir instanceof NRTCachingDirectory) {
|
||||||
|
cdir = ((NRTCachingDirectory)dir).getDelegate();
|
||||||
|
}
|
||||||
|
if (cdir instanceof RateLimitedDirectoryWrapper) {
|
||||||
|
cdir = ((RateLimitedDirectoryWrapper)dir).getDelegate();
|
||||||
|
}
|
||||||
|
if (cdir instanceof TrackingDirectoryWrapper) {
|
||||||
|
cdir = ((TrackingDirectoryWrapper)dir).getDelegate();
|
||||||
|
}
|
||||||
|
return cdir;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAbsolute(String path) {
|
public boolean isAbsolute(String path) {
|
||||||
// TODO: kind of a hack - we don't know what the delegate is, so
|
// TODO: kind of a hack - we don't know what the delegate is, so
|
||||||
|
|
|
@ -22,6 +22,9 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
|
import org.apache.lucene.store.NRTCachingDirectory;
|
||||||
|
import org.apache.lucene.store.RateLimitedDirectoryWrapper;
|
||||||
|
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +41,14 @@ public class MockFSDirectoryFactory extends StandardDirectoryFactory {
|
||||||
// test assumes it can open an IndexWriter when that happens - we
|
// test assumes it can open an IndexWriter when that happens - we
|
||||||
// have a new Directory for the same dir and still an open IW at
|
// have a new Directory for the same dir and still an open IW at
|
||||||
// this point
|
// this point
|
||||||
if (dir instanceof MockDirectoryWrapper) {
|
|
||||||
((MockDirectoryWrapper)dir).setAssertNoUnrefencedFilesOnClose(false);
|
Directory cdir = reduce(dir);
|
||||||
|
cdir = reduce(cdir);
|
||||||
|
cdir = reduce(cdir);
|
||||||
|
|
||||||
|
if (cdir instanceof MockDirectoryWrapper) {
|
||||||
|
((MockDirectoryWrapper)cdir).setAssertNoUnrefencedFilesOnClose(false);
|
||||||
|
((MockDirectoryWrapper)cdir).setPreventDoubleWrite(false);
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -50,4 +59,18 @@ public class MockFSDirectoryFactory extends StandardDirectoryFactory {
|
||||||
// we treat it as file based since this works on most ephem impls
|
// we treat it as file based since this works on most ephem impls
|
||||||
return new File(path).isAbsolute();
|
return new File(path).isAbsolute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Directory reduce(Directory dir) {
|
||||||
|
Directory cdir = dir;
|
||||||
|
if (dir instanceof NRTCachingDirectory) {
|
||||||
|
cdir = ((NRTCachingDirectory)dir).getDelegate();
|
||||||
|
}
|
||||||
|
if (cdir instanceof RateLimitedDirectoryWrapper) {
|
||||||
|
cdir = ((RateLimitedDirectoryWrapper)dir).getDelegate();
|
||||||
|
}
|
||||||
|
if (cdir instanceof TrackingDirectoryWrapper) {
|
||||||
|
cdir = ((TrackingDirectoryWrapper)dir).getDelegate();
|
||||||
|
}
|
||||||
|
return cdir;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ abstract public class BaseTestHarness {
|
||||||
return simpleTag("optimize", args);
|
return simpleTag("optimize", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String simpleTag(String tag, String... args) {
|
public static String simpleTag(String tag, String... args) {
|
||||||
try {
|
try {
|
||||||
StringWriter r = new StringWriter();
|
StringWriter r = new StringWriter();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue