lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcio Napoli <napoli.mar...@gmail.com>
Subject Re: IndexWriter is not closing the FDs (deleted files)
Date Tue, 01 Sep 2015 13:02:13 GMT
Hi András!

Excellent tips!

Thanks,
Napoli

Em ter, 1 de set de 2015 às 09:45, András Péteri <
apeteri@b2international.com> escreveu:

> Hi Napoli,
>
> You could also create an instance of SearcherManager [1], and let it take
> care of tracking IndexSearchers; it can also be use to reopen the
> underlying readers, and close them when they are no longer in use. Calling
> maybeRefresh() or maybeRefreshBlocking() on the manager ensures that a
> reopened reader will be used for newly acquired searchers. You can call
> this method immediately after committing changes to the index, or
> periodically if you don't mind a limited amount of time in which searchers
> return stale results.
>
> The lower-level equivalent which is only concerned with DirectoryReaders is
> ReaderManager [2].
>
> Mike's blog post on the topic [3] has a more detailed description on the
> inner workings.
>
> [1]
>
> http://lucene.apache.org/core/5_3_0/core/org/apache/lucene/search/SearcherManager.html
> [2]
>
> http://lucene.apache.org/core/5_3_0/core/org/apache/lucene/index/ReaderManager.html
> [3]
>
> http://blog.mikemccandless.com/2011/09/lucenes-searchermanager-simplifies.html
>
> Regards,
> András
>
> On Tue, Sep 1, 2015 at 2:16 PM, Marcio Napoli <napoli.marcio@gmail.com>
> wrote:
>
> > Ian,
> >
> > Well remembered!
> >
> > Thanks,
> > Napoli
> >
> > Em ter, 1 de set de 2015 às 09:12, Ian Lea <ian.lea@gmail.com> escreveu:
> >
> > > From a glance, you need to close the old reader after calling
> > > openIfChanged if it gives you a new one.
> > >
> > > See
> > >
> >
> https://lucene.apache.org/core/5_3_0/core/org/apache/lucene/index/DirectoryReader.html#openIfChanged(org.apache.lucene.index.DirectoryReader)
> > > .
> > > You may wish to pay attention to the words about not closing readers
> > > while they may still be in use.
> > >
> > >
> > > --
> > > Ian.
> > >
> > >
> > > On Tue, Sep 1, 2015 at 12:55 PM, Marcio Napoli <
> napoli.marcio@gmail.com>
> > > wrote:
> > > > Hey Anton,
> > > >
> > > > I use this way:
> > > >
> > > > Thanks!
> > > >
> > > > @PostConstruct
> > > > public void create() {
> > > > final String parent = System.getProperty("jboss.server.data.dir");
> > > > final File indexFullPath = new File(parent, CIDADAO_INDEX_PATH);
> > > >                 try {
> > > > final FSDirectory directory = FSDirectory.open(indexFullPath);
> > > >                         this.openIndex(directory);
> > > >                 } catch (Exception e) {
> > > > logger.error("Problema no índice lucene para Cidadão", e);
> > > > throw EJBUtil.rollbackNE(e);
> > > > }
> > > > }
> > > >
> > > > private void openIndex(Directory directory) throws IOException {
> > > > final IndexWriterConfig config = new IndexWriterConfig(LUCENE_4_10_3,
> > > > DEFAULT_ANALYZER);
> > > > config.setMaxThreadStates(2);
> > > > config.setCheckIntegrityAtMerge(true);
> > > > this.writer = new IndexWriter(directory, config);
> > > > this.reader = DirectoryReader.open(this.writer, true);
> > > > }
> > > >
> > > >
> > > > private void addToIndex(final CidadaoBean cidadaoBean, boolean
> commit)
> > {
> > > > if (cidadaoBean == null || !cidadaoBean.isSetId()) {
> > > > return;
> > > > }
> > > >
> > > > try {
> > > > CidadaoHelper.addToIndex(writer, cidadaoBean, commit);
> > > > if (commit) {
> > > > DirectoryReader newReader =
> DirectoryReader.openIfChanged(this.reader);
> > > > if (newReader != null) {
> > > > this.reader = newReader;
> > > > }
> > > > }
> > > > } catch (Exception e) {
> > > > logger.error("Não foi possível inserir o Cidadao no índice Lucene
> \n" +
> > > > cidadaoBean, e);
> > > > e.printStackTrace();
> > > > }
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > > Em seg, 31 de ago de 2015 às 21:13, Anton Zenkov <
> > > azenkov@crimsonhexagon.com>
> > > > escreveu:
> > > >
> > > >> Are you sure you are not holding open readers somewhere?
> > > >>
> > > >> On Mon, Aug 31, 2015 at 7:46 PM, Marcio Napoli <
> > napoli.marcio@gmail.com
> > > >
> > > >> wrote:
> > > >>
> > > >> > Hey! :)
> > > >> >
> > > >> > It seems IndexWriter is not closing the descriptors of the removed
> > > files,
> > > >> > see the log below.
> > > >> >
> > > >> > Thanks,
> > > >> > Napoli
> > > >> >
> > > >> > [root@server01 log]# ls -l /proc/59491/fd  | grep index
> > > >> > l-wx------. 1 wildfly wildfly 64 Ago 31 11:26 429 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/write.lock
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 529 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_4.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 530 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_3.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 531 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_2.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 532 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_1.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 533 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_0.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 535 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_a.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 536 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_9.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 537 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_8.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 538 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_7.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 539 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_6.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 540 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_5_Lucene41_0.doc
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 541 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_5_Lucene41_0.pos
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 542 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_5_Lucene41_0.tim
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 543 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_5.nvd
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 544 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_5.fdt
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 11:26 545 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_5_Lucene410_0.dvd
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 619 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_o.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 676 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_k.cfs
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 677 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_j_Lucene41_0.doc
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 678 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_j_Lucene41_0.pos
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 679 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_j_Lucene41_0.tim
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 680 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_j.nvd
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 681 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_j.fdt
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 682 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_j_Lucene410_0.dvd
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 685 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_n_Lucene41_0.doc
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 686 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_n_Lucene41_0.pos
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 687 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_n_Lucene41_0.tim
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 688 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_n.nvd
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 689 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_n.fdt
> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 690 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_n_Lucene410_0.dvd
> > > >> > (deleted)
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 730 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_15.cfs
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 737 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_r_Lucene41_0.doc
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 738 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_r_Lucene41_0.pos
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 739 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_r_Lucene41_0.tim
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 740 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_r.nvd
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 741 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_r.fdt
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 742 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_r_Lucene410_0.dvd
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 755 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_w_Lucene41_0.doc
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 756 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_w_Lucene41_0.pos
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 757 ->
> > > >> >
> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_w_Lucene41_0.tim
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 758 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_w.nvd
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 759 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_w.fdt
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 760 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_w_Lucene410_0.dvd
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 761 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_14_Lucene41_0.doc
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 762 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_14_Lucene41_0.pos
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 763 ->
> > > >> >
> > > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_14_Lucene41_0.tim
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 765 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_14.nvd
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 766 ->
> > > >> > /usr/local/wildfly-2.0/standalone/data/index/cidadao/_14.fdt
> > > >> > lr-x------. 1 wildfly wildfly 64 Ago 31 20:25 767 ->
> > > >> >
> > >
> /usr/local/wildfly-2.0/standalone/data/index/cidadao/_14_Lucene410_0.dvd
> > > >> >
> > > >>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message