mirror of https://github.com/apache/lucene.git
SOLR-670: Rollback should reset not only adds/deletesById/deletesByQuery counts but also cumulative counts of them.
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@824380 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
afcfa3c1c2
commit
1f9e0eb390
|
@ -470,9 +470,12 @@ public class DirectUpdateHandler2 extends UpdateHandler {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
iwCommit.unlock();
|
iwCommit.unlock();
|
||||||
addCommands.set(0);
|
addCommandsCumulative.set(
|
||||||
deleteByIdCommands.set(0);
|
addCommandsCumulative.get() - addCommands.getAndSet( 0 ) );
|
||||||
deleteByQueryCommands.set(0);
|
deleteByIdCommandsCumulative.set(
|
||||||
|
deleteByIdCommandsCumulative.get() - deleteByIdCommands.getAndSet( 0 ) );
|
||||||
|
deleteByQueryCommandsCumulative.set(
|
||||||
|
deleteByQueryCommandsCumulative.get() - deleteByQueryCommands.getAndSet( 0 ) );
|
||||||
numErrors.set(error ? 1 : 0);
|
numErrors.set(error ? 1 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,15 +176,29 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {
|
||||||
// commit "A"
|
// commit "A"
|
||||||
SolrCore core = h.getCore();
|
SolrCore core = h.getCore();
|
||||||
UpdateHandler updater = core.getUpdateHandler();
|
UpdateHandler updater = core.getUpdateHandler();
|
||||||
|
assertTrue( updater instanceof DirectUpdateHandler2 );
|
||||||
|
DirectUpdateHandler2 duh2 = (DirectUpdateHandler2)updater;
|
||||||
CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
|
CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
|
||||||
cmtCmd.waitSearcher = true;
|
cmtCmd.waitSearcher = true;
|
||||||
|
assertEquals( 1, duh2.addCommands.get() );
|
||||||
|
assertEquals( 1, duh2.addCommandsCumulative.get() );
|
||||||
|
assertEquals( 0, duh2.commitCommands.get() );
|
||||||
updater.commit(cmtCmd);
|
updater.commit(cmtCmd);
|
||||||
|
assertEquals( 0, duh2.addCommands.get() );
|
||||||
|
assertEquals( 1, duh2.addCommandsCumulative.get() );
|
||||||
|
assertEquals( 1, duh2.commitCommands.get() );
|
||||||
|
|
||||||
addSimpleDoc("B");
|
addSimpleDoc("B");
|
||||||
|
|
||||||
// rollback "B"
|
// rollback "B"
|
||||||
RollbackUpdateCommand rbkCmd = new RollbackUpdateCommand();
|
RollbackUpdateCommand rbkCmd = new RollbackUpdateCommand();
|
||||||
|
assertEquals( 1, duh2.addCommands.get() );
|
||||||
|
assertEquals( 2, duh2.addCommandsCumulative.get() );
|
||||||
|
assertEquals( 0, duh2.rollbackCommands.get() );
|
||||||
updater.rollback(rbkCmd);
|
updater.rollback(rbkCmd);
|
||||||
|
assertEquals( 0, duh2.addCommands.get() );
|
||||||
|
assertEquals( 1, duh2.addCommandsCumulative.get() );
|
||||||
|
assertEquals( 1, duh2.rollbackCommands.get() );
|
||||||
|
|
||||||
// search - "B" should not be found.
|
// search - "B" should not be found.
|
||||||
Map<String,String> args = new HashMap<String, String>();
|
Map<String,String> args = new HashMap<String, String>();
|
||||||
|
@ -213,9 +227,17 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {
|
||||||
// commit "A", "B"
|
// commit "A", "B"
|
||||||
SolrCore core = h.getCore();
|
SolrCore core = h.getCore();
|
||||||
UpdateHandler updater = core.getUpdateHandler();
|
UpdateHandler updater = core.getUpdateHandler();
|
||||||
|
assertTrue( updater instanceof DirectUpdateHandler2 );
|
||||||
|
DirectUpdateHandler2 duh2 = (DirectUpdateHandler2)updater;
|
||||||
CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
|
CommitUpdateCommand cmtCmd = new CommitUpdateCommand(false);
|
||||||
cmtCmd.waitSearcher = true;
|
cmtCmd.waitSearcher = true;
|
||||||
|
assertEquals( 2, duh2.addCommands.get() );
|
||||||
|
assertEquals( 2, duh2.addCommandsCumulative.get() );
|
||||||
|
assertEquals( 0, duh2.commitCommands.get() );
|
||||||
updater.commit(cmtCmd);
|
updater.commit(cmtCmd);
|
||||||
|
assertEquals( 0, duh2.addCommands.get() );
|
||||||
|
assertEquals( 2, duh2.addCommandsCumulative.get() );
|
||||||
|
assertEquals( 1, duh2.commitCommands.get() );
|
||||||
|
|
||||||
// search - "A","B" should be found.
|
// search - "A","B" should be found.
|
||||||
Map<String,String> args = new HashMap<String, String>();
|
Map<String,String> args = new HashMap<String, String>();
|
||||||
|
@ -240,7 +262,13 @@ public class DirectUpdateHandlerTest extends AbstractSolrTestCase {
|
||||||
|
|
||||||
// rollback "B"
|
// rollback "B"
|
||||||
RollbackUpdateCommand rbkCmd = new RollbackUpdateCommand();
|
RollbackUpdateCommand rbkCmd = new RollbackUpdateCommand();
|
||||||
|
assertEquals( 1, duh2.deleteByIdCommands.get() );
|
||||||
|
assertEquals( 1, duh2.deleteByIdCommandsCumulative.get() );
|
||||||
|
assertEquals( 0, duh2.rollbackCommands.get() );
|
||||||
updater.rollback(rbkCmd);
|
updater.rollback(rbkCmd);
|
||||||
|
assertEquals( 0, duh2.deleteByIdCommands.get() );
|
||||||
|
assertEquals( 0, duh2.deleteByIdCommandsCumulative.get() );
|
||||||
|
assertEquals( 1, duh2.rollbackCommands.get() );
|
||||||
|
|
||||||
// search - "B" should be found.
|
// search - "B" should be found.
|
||||||
assertQ("\"B\" should be found.", req
|
assertQ("\"B\" should be found.", req
|
||||||
|
|
Loading…
Reference in New Issue