mirror of https://github.com/apache/lucene.git
SOLR-283: autoCommit after delete
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@552698 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0985f37184
commit
2adc9df23a
|
@ -103,6 +103,8 @@ Bug Fixes
|
|||
2. autoCommit/maxDocs was not working properly when large autoCommit/maxTime
|
||||
was specified (klaas)
|
||||
|
||||
3. SOLR-283: autoCommit was not working after delete. (ryan)
|
||||
|
||||
Other Changes
|
||||
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the
|
||||
build scripts to make two jars: apache-solr-1.3.jar and
|
||||
|
|
|
@ -304,6 +304,10 @@ public class DirectUpdateHandler2 extends UpdateHandler {
|
|||
} finally {
|
||||
iwCommit.unlock();
|
||||
}
|
||||
|
||||
if( tracker.timeUpperBound > 0 ) {
|
||||
tracker.scheduleCommitWithin( tracker.timeUpperBound );
|
||||
}
|
||||
}
|
||||
|
||||
// why not return number of docs deleted?
|
||||
|
@ -351,6 +355,10 @@ public class DirectUpdateHandler2 extends UpdateHandler {
|
|||
}
|
||||
numDocsDeleted.getAndAdd(totDeleted);
|
||||
madeIt=true;
|
||||
|
||||
if( tracker.timeUpperBound > 0 ) {
|
||||
tracker.scheduleCommitWithin( tracker.timeUpperBound );
|
||||
}
|
||||
} finally {
|
||||
if (!madeIt) {
|
||||
numErrors.incrementAndGet();
|
||||
|
@ -568,7 +576,7 @@ public class DirectUpdateHandler2 extends UpdateHandler {
|
|||
}
|
||||
log.info("closed " + this);
|
||||
}
|
||||
|
||||
|
||||
/** Helper class for tracking autoCommit state.
|
||||
*
|
||||
* Note: This is purely an implementation detail of autoCommit and will
|
||||
|
@ -605,6 +613,23 @@ public class DirectUpdateHandler2 extends UpdateHandler {
|
|||
SolrCore.log.info("AutoCommit: " + this);
|
||||
}
|
||||
|
||||
/** schedeule individual commits */
|
||||
public synchronized void scheduleCommitWithin(long commitMaxTime)
|
||||
{
|
||||
// Check if there is a commit already scheduled for longer then this time
|
||||
if( pending != null &&
|
||||
pending.getDelay(TimeUnit.MILLISECONDS) >= commitMaxTime )
|
||||
{
|
||||
pending.cancel(false);
|
||||
pending = null;
|
||||
}
|
||||
|
||||
// schedule a new commit
|
||||
if( pending == null ) {
|
||||
pending = scheduler.schedule( this, commitMaxTime, TimeUnit.MILLISECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
/** Indicate that documents have been added
|
||||
*/
|
||||
public void addedDocument() {
|
||||
|
|
|
@ -156,6 +156,13 @@ public class AutoCommitTest extends AbstractSolrTestCase {
|
|||
// But not this one
|
||||
assertQ("should find none", req("id:530") ,"//result[@numFound=0]" );
|
||||
|
||||
// Delete the document
|
||||
assertU( delI("529") );
|
||||
assertQ("deleted, but should still be there", req("id:529") ,"//result[@numFound=1]" );
|
||||
// Wait longer then the autocommit time
|
||||
Thread.sleep( 1000 );
|
||||
assertQ("deleted and time has passed", req("id:529") ,"//result[@numFound=0]" );
|
||||
|
||||
// now make the call 10 times really fast and make sure it
|
||||
// only commits once
|
||||
req.setContentStreams( toContentStreams(
|
||||
|
@ -164,7 +171,7 @@ public class AutoCommitTest extends AbstractSolrTestCase {
|
|||
handler.handleRequest( req, rsp );
|
||||
}
|
||||
assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
|
||||
assertEquals( 1, tracker.autoCommitCount );
|
||||
assertEquals( 2, tracker.autoCommitCount );
|
||||
|
||||
// Wait longer then the autocommit time
|
||||
Thread.sleep( 1000 );
|
||||
|
@ -173,6 +180,6 @@ public class AutoCommitTest extends AbstractSolrTestCase {
|
|||
|
||||
assertQ("now it should", req("id:500") ,"//result[@numFound=1]" );
|
||||
assertQ("but not this", req("id:531") ,"//result[@numFound=0]" );
|
||||
assertEquals( 2, tracker.autoCommitCount );
|
||||
assertEquals( 3, tracker.autoCommitCount );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue