Is anyone aware of a threading issues within SI4T?
We have a custom Elasticsearch indexer plugged into SI4T that uses JEST to check and create necessary Elasticsearch indexes based on the publication id (e.g. publication_10) passed in to the commit method and then index documents into these indexes. The code is based pretty much on the SOLR example that comes with with SI4T, apart from the Elasticsearch/JEST parts.
Our blueprint is a traditional diamond (content/templates) and has a master website publication for pages that several child publications inherit from.
We've noticed that when we publish pages via the static components that are used on them, from the master (with the include in Child Publications option) we can see a load of transactions in the queue - all as expected apart from we end up with pages from different publications indexed into the wrong index - so index "publication_36" has a document with id "tcm:51-xxxx-64".
I don't quite understand storage extensions or the effect of a multi-threaded Deployer - but it seems like because parts of SI4T are singleton, the multi-threaded Deployer is altering the publication id value passed in to the SI4T storage classes.
UPDATE
cd_storage:
<Storage
Type="persistence" Id="si4tdb" dialect="MSSQL"
Class="com.tridion.storage.si4t.JPASearchDAOFactory">
<Pool Type="jdbc" Size="5" MonitorInterval="60" IdleTimeout="120" CheckoutTimeout="120" />
<DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<Property Name="serverName" Value="...." />
<Property Name="portNumber" Value="1433" />
<Property Name="databaseName" Value="Tridion_Broker" />
<Property Name="user" Value="..." />
<Property Name="password" Value="..." />
</DataSource>
<Indexer
Class="org.si4t.elasticsearch.ElasticsearchIndexer"
Url="http://localhost:9200"
Clustername="http"
DocExtensions="pdf,docx,doc,xls,xlsx,pptx,ppt"
Mapping=" ..."/>
</Storage>
<Storage Type="filesystem"
Class="com.tridion.storage.si4t.FSSearchDAOFactory"
Id="301FileSystem" defaultFilesystem="false" defaultStorage="false">
<Root Path="D:\Live\Redirects" />
<Indexer
Class="org.si4t.elasticsearch.ElasticsearchIndexer"
Clustername="http"
Url="http://localhost:9200"
DocExtensions="pdf,docx,doc,xls,xlsx,pptx,ppt,txt"
Mapping="..."/>
</Storage>
<Storage Type="filesystem"
Class="com.tridion.storage.si4t.FSSearchDAOFactory"
Id="si4tFile" defaultFilesystem="false" defaultStorage="false">
<Root Path="D:\Live\Binaries" />
<Indexer
Class="org.si4t.elasticsearch.ElasticsearchIndexer"
Clustername="http"
Url="http://localhost:9200"
DocExtensions="pdf,docx,doc,xls,xlsx,pptx,ppt"
Mapping="..."/>
</Storage>
ELasticsearch indexer can be found here. The approach was to use the publication id passed to the commit method to form the index name - check if it exists (create if not) - and then index documents using this index name.
Example log file can be found here. I can see on line 1116 for exmaple, where several pages across publications have all gone into index "publication_36".
pool-1-thread-6 2015-03-06 16:25:42,072 DEBUG ElasticsearchIndexer - {"took":483,"errors":false,"items":[{"index":{"_index":"publication_36","_type":"Pages","_id":"tcm:52-1786-64","_version":1,"status":201}},{"index":{"_index":"publication_36","_type":"Pages","_id":"tcm:51-1786-64","_version":1,"status":201}},{"index":{"_index":"publication_36","_type":"Pages","_id":"tcm:49-1786-64","_version":1,"status":201}},{"index":{"_index":"publication_36","_type":"Pages","_id":"tcm:47-1786-64","_version":1,"status":201}},{"index":{"_index":"publication_36","_type":"Pages","_id":"tcm:40-1786-64","_version":1,"status":201}},{"index":{"_index":"publication_36","_type":"Pages","_id":"tcm:36-1786-64","_version":1,"status":201}}]}