<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Resource leak when lucene indexes (alt.) contentStore? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266226#M219356</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I further investigated the problem I described in my earlier post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's not a resource leak, but the lucene indexer is using much more 'contentstore resources' since alfresco 3.4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me explain this a bit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. content in a contentStore is read via an implementation of ContentStore.getReader()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. the access to this content(stream) is released via an implementation of ContentStreamListener.contentStreamClosed()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In earlier versions these 2 methods were called after eachother: contentStreamClosed() was called before the next getReader() was called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is not the case anymore, in ADMLucenIndexerImpl.flushPending(), getReader() is called via readDocuments(), while contentStreamClosed() is called via writer.addDocument(doc) which is in a loop over all documents (in a batch). So this implementation keeps multiple streams opened (~ size of lucene.indexer.batchSize).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the default contentStore (file system) this is probably unnoted because the os provides a huge number of file handles. In our non-default contentstore (castorContentStore) however we use http connections to access the contentstore and we only configured a pool with a limited number of connections (much smaller than the batchSize). So we are able to solve the issue by tuning the castor connection pool to the lucene batch size.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This leaves me with 2 questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. does the above analysis make sense?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. is there a real reason to have these concurrent open streams or was this introduced 'by accident'?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Aug 2012 20:11:15 GMT</pubDate>
    <dc:creator>dirko</dc:creator>
    <dc:date>2012-08-16T20:11:15Z</dc:date>
    <item>
      <title>Resource leak when lucene indexes (alt.) contentStore?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266225#M219355</link>
      <description>Hello,I've been investigating a problem we experience in a {Alfresco 4, lucene, alternative contentStore} environment and which was not occurring in 3.2. We are using an alternative contentStore (castorContentStore, cfr. http://forge.alfresco.com/gf/project/alfresco2castor/). To understand the issue</description>
      <pubDate>Sun, 15 Jul 2012 22:55:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266225#M219355</guid>
      <dc:creator>dirko</dc:creator>
      <dc:date>2012-07-15T22:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Resource leak when lucene indexes (alt.) contentStore?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266226#M219356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I further investigated the problem I described in my earlier post.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's not a resource leak, but the lucene indexer is using much more 'contentstore resources' since alfresco 3.4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me explain this a bit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. content in a contentStore is read via an implementation of ContentStore.getReader()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. the access to this content(stream) is released via an implementation of ContentStreamListener.contentStreamClosed()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In earlier versions these 2 methods were called after eachother: contentStreamClosed() was called before the next getReader() was called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is not the case anymore, in ADMLucenIndexerImpl.flushPending(), getReader() is called via readDocuments(), while contentStreamClosed() is called via writer.addDocument(doc) which is in a loop over all documents (in a batch). So this implementation keeps multiple streams opened (~ size of lucene.indexer.batchSize).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the default contentStore (file system) this is probably unnoted because the os provides a huge number of file handles. In our non-default contentstore (castorContentStore) however we use http connections to access the contentstore and we only configured a pool with a limited number of connections (much smaller than the batchSize). So we are able to solve the issue by tuning the castor connection pool to the lucene batch size.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This leaves me with 2 questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. does the above analysis make sense?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. is there a real reason to have these concurrent open streams or was this introduced 'by accident'?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 20:11:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266226#M219356</guid>
      <dc:creator>dirko</dc:creator>
      <dc:date>2012-08-16T20:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Resource leak when lucene indexes (alt.) contentStore?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266227#M219357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Dirk&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you have a point&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have logged &lt;/SPAN&gt;&lt;A href="https://issues.alfresco.com/jira/browse/ALF-15857" rel="nofollow noopener noreferrer"&gt;https://issues.alfresco.com/jira/browse/ALF-15857&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The indexer was recently reorganized so that it 'batched' together all index reads in readDocuments(), before writing to the index in a single go. This was to avoid the context switching involved in changing between writer and reader and all the flushing involved.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, it looks like we then introduced the problem you describe. As the documents to be added to the index retain an open reader until they are consumed and closed. So we were simultaneously opening streams for all documents in the transaction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I will be able to work around this by wrapping the Reader with a 'lazy' one that only triggers the opening of the content input stream when it is first accessed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll check in an experimental fix and let you know how it goes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for bringing this to our attention.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Sep 2012 11:40:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/resource-leak-when-lucene-indexes-alt-contentstore/m-p/266227#M219357</guid>
      <dc:creator>dward</dc:creator>
      <dc:date>2012-09-06T11:40:45Z</dc:date>
    </item>
  </channel>
</rss>

