mirror of https://github.com/apache/lucene.git
SOLR-8449: Fix the core restore functionality to allow restoring multiple times on the same core
This commit is contained in:
parent
f1c044a2d7
commit
4381018b77
|
@ -267,6 +267,9 @@ Bug Fixes
|
||||||
|
|
||||||
* SOLR-8779: Fix missing InterruptedException handling in ZkStateReader.java (Varun Thacker)
|
* SOLR-8779: Fix missing InterruptedException handling in ZkStateReader.java (Varun Thacker)
|
||||||
|
|
||||||
|
* SOLR-8449: Fix the core restore functionality to allow restoring multiple times on the same core
|
||||||
|
(Johannes Brucher, Varun Thacker)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
|
* SOLR-7876: Speed up queries and operations that use many terms when timeAllowed has not been
|
||||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.solr.handler;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
@ -55,7 +58,8 @@ public class RestoreCore implements Callable<Boolean> {
|
||||||
private boolean doRestore() throws Exception {
|
private boolean doRestore() throws Exception {
|
||||||
|
|
||||||
Path backupPath = Paths.get(backupLocation).resolve(backupName);
|
Path backupPath = Paths.get(backupLocation).resolve(backupName);
|
||||||
String restoreIndexName = "restore." + backupName;
|
SimpleDateFormat dateFormat = new SimpleDateFormat(SnapShooter.DATE_FMT, Locale.ROOT);
|
||||||
|
String restoreIndexName = "restore." + dateFormat.format(new Date());
|
||||||
String restoreIndexPath = core.getDataDir() + restoreIndexName;
|
String restoreIndexPath = core.getDataDir() + restoreIndexName;
|
||||||
|
|
||||||
Directory restoreIndexDir = null;
|
Directory restoreIndexDir = null;
|
||||||
|
|
|
@ -138,36 +138,43 @@ public class TestRestoreCore extends SolrJettyTestBase {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Modify existing index before we call restore.
|
|
||||||
|
|
||||||
//Delete a few docs
|
|
||||||
int numDeletes = TestUtil.nextInt(random(), 1, nDocs);
|
|
||||||
for(int i=0; i<numDeletes; i++) {
|
|
||||||
masterClient.deleteByQuery("id:" + i);
|
|
||||||
}
|
|
||||||
masterClient.commit();
|
|
||||||
|
|
||||||
//Add a few more
|
int numRestoreTests = TestUtil.nextInt(random(), 1, 5);
|
||||||
int moreAdds = TestUtil.nextInt(random(), 1, 100);
|
|
||||||
for (int i=0; i<moreAdds; i++) {
|
for (int attempts=0; attempts<numRestoreTests; attempts++) {
|
||||||
SolrInputDocument doc = new SolrInputDocument();
|
//Modify existing index before we call restore.
|
||||||
doc.addField("id", i + nDocs);
|
|
||||||
doc.addField("name", "name = " + (i + nDocs));
|
//Delete a few docs
|
||||||
masterClient.add(doc);
|
int numDeletes = TestUtil.nextInt(random(), 1, nDocs);
|
||||||
}
|
for(int i=0; i<numDeletes; i++) {
|
||||||
//Purposely not calling commit once in a while. There can be some docs which are not committed
|
masterClient.deleteByQuery("id:" + i);
|
||||||
if (usually()) {
|
}
|
||||||
masterClient.commit();
|
masterClient.commit();
|
||||||
|
|
||||||
|
//Add a few more
|
||||||
|
int moreAdds = TestUtil.nextInt(random(), 1, 100);
|
||||||
|
for (int i=0; i<moreAdds; i++) {
|
||||||
|
SolrInputDocument doc = new SolrInputDocument();
|
||||||
|
doc.addField("id", i + nDocs);
|
||||||
|
doc.addField("name", "name = " + (i + nDocs));
|
||||||
|
masterClient.add(doc);
|
||||||
|
}
|
||||||
|
//Purposely not calling commit once in a while. There can be some docs which are not committed
|
||||||
|
if (usually()) {
|
||||||
|
masterClient.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
TestReplicationHandlerBackup.runBackupCommand(masterJetty, ReplicationHandler.CMD_RESTORE, params);
|
||||||
|
|
||||||
|
while (!fetchRestoreStatus()) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
//See if restore was successful by checking if all the docs are present again
|
||||||
|
verifyDocs(nDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestReplicationHandlerBackup.runBackupCommand(masterJetty, ReplicationHandler.CMD_RESTORE, params);
|
|
||||||
|
|
||||||
while (!fetchRestoreStatus()) {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
//See if restore was successful by checking if all the docs are present again
|
|
||||||
verifyDocs(nDocs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue