diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 1ca68e2860a..0884640c4aa 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -379,6 +379,9 @@ Bug Fixes * SOLR-3352: eDismax: pf2 should kick in for a query with 2 terms (janhoy) +* SOLR-3361: ReplicationHandler "maxNumberOfBackups" doesn't work if backups are triggered on commit + (James Dyer, Tomas Fernandez Lobbe) + Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index 11c226f1027..f954118a336 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -993,9 +993,13 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw ***/ } if (snapshoot) { - try { + try { + int numberToKeep = numberBackupsToKeep; + if (numberToKeep < 1) { + numberToKeep = Integer.MAX_VALUE; + } SnapShooter snapShooter = new SnapShooter(core, null); - snapShooter.createSnapAsync(currentCommitPoint, ReplicationHandler.this); + snapShooter.createSnapAsync(currentCommitPoint, numberToKeep, ReplicationHandler.this); } catch (Exception e) { LOG.error("Exception while snapshooting", e); } diff --git a/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml b/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml index 13a14dac232..ed223e09609 100644 --- a/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml +++ b/solr/core/src/test-files/solr/conf/solrconfig-master1-keepOneBackup.xml @@ -32,7 +32,7 @@ - commit + commit schema-replication2.xml:schema.xml 1 diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java index 05d79dcc9ec..4efa357e15f 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java +++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java @@ -243,7 +243,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { } public void test() throws Exception { - doTestReplicateAfterCoreReload(); + doTestReplicateAfterCoreReload(); doTestDetails(); doTestReplicateAfterWrite2Slave(); doTestIndexAndConfigReplication(); @@ -776,7 +776,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { if(random().nextBoolean()) { configFile = "solrconfig-master1-keepOneBackup.xml"; addNumberToKeepInRequest = false; - backupKeepParamName = ReplicationHandler.NUMBER_BACKUPS_TO_KEEP_INIT_PARAM; } masterJetty.stop(); @@ -864,8 +863,16 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { File[] snapDir = new File[2]; String firstBackupTimestamp = null; for(int i=0 ; i<2 ; i++) { - BackupThread backupThread = new BackupThread(addNumberToKeepInRequest, backupKeepParamName); - backupThread.start(); + BackupThread backupThread = null; + if(!addNumberToKeepInRequest) { + if(random().nextBoolean()) { + masterClient.commit(); + } else { + backupThread = new BackupThread(addNumberToKeepInRequest, backupKeepParamName); + backupThread.start(); + } + } + File dataDir = new File(master.getDataDir()); @@ -890,7 +897,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 { waitCnt++; } - if(backupThread.fail != null) { + if(backupThread!= null && backupThread.fail != null) { fail(backupThread.fail); }