Can we move this to patch files within the JIRA issue please. Will make it easier to review and help out a as a patch to current trunk.
--j Jim Murphy wrote: > > > > Yonik Seeley-2 wrote: >> >> ...your code snippit elided and edited below ... >> > > > > Don't take this code as correct (or even compiling) but is this the > essence? I moved shared access to the writer inside the read lock and > kept the other non-commit bits to the write lock. I'd need to rethink the > locking in a more fundamental way but is this close to idea? > > > > public void commit(CommitUpdateCommand cmd) throws IOException { > > if (cmd.optimize) { > optimizeCommands.incrementAndGet(); > } else { > commitCommands.incrementAndGet(); > } > > Future[] waitSearcher = null; > if (cmd.waitSearcher) { > waitSearcher = new Future[1]; > } > > boolean error=true; > iwCommit.lock(); > try { > log.info("start "+cmd); > > if (cmd.optimize) { > closeSearcher(); > openWriter(); > writer.optimize(cmd.maxOptimizeSegments); > } > finally { > iwCommit.unlock(); > } > > > iwAccess.lock(); > try > { > writer.commit(); > } > finally > { > iwAccess.unlock(); > } > > iwCommit.lock(); > try > { > callPostCommitCallbacks(); > if (cmd.optimize) { > callPostOptimizeCallbacks(); > } > // open a new searcher in the sync block to avoid opening it > // after a deleteByQuery changed the index, or in between deletes > // and adds of another commit being done. > core.getSearcher(true,false,waitSearcher); > > // reset commit tracking > tracker.didCommit(); > > log.info("end_commit_flush"); > > error=false; > } > finally { > iwCommit.unlock(); > addCommands.set(0); > deleteByIdCommands.set(0); > deleteByQueryCommands.set(0); > numErrors.set(error ? 1 : 0); > } > > // if we are supposed to wait for the searcher to be registered, then > we should do it > // outside of the synchronized block so that other update operations > can proceed. > if (waitSearcher!=null && waitSearcher[0] != null) { > try { > waitSearcher[0].get(); > } catch (InterruptedException e) { > SolrException.log(log,e); > } catch (ExecutionException e) { > SolrException.log(log,e); > } > } > } > > > > -- View this message in context: http://www.nabble.com/Autocommit-blocking-adds---AutoCommit-Speedup--tp23435224p23455432.html Sent from the Solr - User mailing list archive at Nabble.com.