Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-648
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Shay Banon
Reporter: Jake Robb
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.

JdbcDirectoryStore should be able to release its datasource if so configured

Created: 09/Jun/08 08:51 AM   Updated: 12/Jul/08 09:28 AM
Component/s: Compass::Core
Affects Version/s: 2.0.1
Fix Version/s: None

 Description  « Hide
Currently, when using a JDBC store with Compass, the only option is to have it acquire a database connection once and keep it for the life of the application.

While this may be desirable in certain cases, my application needs to have several instances of Compass (a security measure deemed necessary to keep one customer's data totally separate from the next), and this means that in its current state, Compass holds one database connection for each of our customers. In our production environment, that would mean dozens of database connections. It would be better in my case if Compass acquired and released database connections on a per-CompassSession basis.

Any feedback or suggestions you may have on the subject would be appreciated. Thanks!

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 10/Jun/08 05:30 PM
Compass releases connections acquired by the datasource. It only acquires them when performing operations and then releases them. Should that be enough, or do you see a bug there?

Jake Robb added a comment - 12/Jun/08 04:10 PM
I just looked through the Compass code, and it does appear that Compass releases connections like I expected it to.

I'm getting exceptions from other parts of my application indicating that there are no connections available in the connection pool. Upon further investigation, it appears that this is because Compass is using them (even though no searches are going on at the time). It appears to be related to Compass's scheduled tasks, but that's all the information I have at this point.

I will continue to look into the issue on my end and report back when I know more. In the meantime, if you have any tips on where I should be looking, I'd appreciate it.

Shay Banon added a comment - 12/Jun/08 04:32 PM
There isn't a lot of work done concurrently by Compass in a scheduled manner. There is the optimizer, which might cause that, I am not sure though. Maybe try and understand from which scheduled task this happens (breakpoint?)?

Sorry for not helping more... .

brian mcsweeney added a comment - 12/Jul/08 09:28 AM
Hi folks,

I've seen this issue myself with mysql where database connections aren't getting released. I took Shay's advice and when I comment out the optimizer the problem goes away.

Something in the optimizer must cause it as a problem. My spring configuration is below:

<!-- database storage of index -->
	<bean id="compass" class="org.compass.spring.LocalCompassBean">
		<property name="classMappings">
		<property name="transactionManager" ref="transactionManager" />
		<property name="compassConfiguration" ref="annotationConfiguration" />
		<property name="compassSettings">

				<prop key="compass.engine.connection">jdbc://jdbc:mysql://localhost/lportal?relaxAutoCommit=true&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;emulateLocators=true</prop>
				<!-- Optimizer settings 
				<prop key="compass.engine.optimizer.schedule">false</prop>
				<prop key="compass.engine.optimizer.type">org.compass.core.lucene.engine.optimizer.AdaptiveOptimizer</prop>
				<prop key="compass.engine.optimizer.adptive.mergeFactor">4</prop>
				<prop key="compass.engine.optimizer.schedule.period">10</prop>
				<prop key="compass.engine.optimizer.schedule.daemon">true</prop>
				<prop key="compass.engine.optimizer.schedule.fixedRate">false</prop>
				 End Optimizer settings -->

				<!-- Use non compound index format when using JDBC Directory -->
				<prop key="compass.engine.useCompoundFile">false</prop>
				<!-- Customize locking mechanism to handle PhantomRead exceptions: interval is in millis and timeout is in seconds -->
				<prop key="compass.transaction.lockPollInterval">200</prop>
				<prop key="compass.transaction.lockTimeout">30</prop>
				<!-- turn it off -->
				<prop key="compass.engine.cacheIntervalInvalidation">-1</prop>

				By Default, compass uses StandardAnalyzer for indexing and searching. StandardAnalyzer
				will use certain stop words (stop words are not indexed and hence not searcheable) which are
				valid search terms in the DataSource World. So we need to provide our won Analyzer.
				<prop key="compass.engine.analyzer.default.type">snowball</prop>
				<prop key="">English</prop>

				<!--  start transactions -->
				<prop key="compass.transaction.factory">org.compass.spring.transaction.SpringSyncTransactionFactory</prop>
				<prop key="compass.transaction.isolation">read_committed</prop>
				<prop key="compass.transaction.commitBeforeCompletion">true</prop>
				<!--  end transactions -->

		<property name="dataSource" ref="dataSource" />