View Issue Details

IDProjectCategoryView StatusLast Update
0002970SymmetricDSBugpublic2017-11-05 20:57
ReporternuralimcaAssigned Tomaxwellpettit 
PriorityhighSeveritymajorReproducibilitysometimes
Status assignedResolutionopen 
Product Version3.7.33 
Target VersionFixed in Version 
Summary0002970: db connection leaks after engine stop
DescriptionDear All,

I have embedded Symmetric DS 3.7.33 into my webapp. I have Web UI which allows user to start and stop Symmetric DS Engine.

When user click on Stop button, I internally call below method on server side:
ISymmetricEngine.destroy()

Which first stop() and then destroy() the engine.

I found that after destroy() called if I check then there are few database connections are not closed (connection for database associated with given engine).

Overall, even after calling destroy() on engine, there are database connection leak.

I was expecting that once I call destroy() method all the database connection should be closed.

Please suggest if there is any other cleaner way to stop/destroy engine so that database connection leak is not happened or fix database connection leak issue with stop/destroy of engine.

Thanks,
Nurali
Steps To Reproduce1. start source engine for source database with stream.to.file.enabled=true
2. start target engine for target database.
3. make sure there is active data copy going on, like keep huge initial load and on start of both engine data is continuously getting copied from source to target.
4. stop source engine and stop target engine.
5. try to delete target database.

For step 5, delete of target database is failing with error that there are active connections.
TagsNo tags attached.

Activities

nuralimca

2017-01-25 06:10

reporter   ~0000960

Dear All,

*Issue Details:*
I have also analyzed the issue. The issue happens when there is continuous data copy happening between source and target engine. This issue generally easily reproduce for initial load with some good amount of data to be copied.

When I call ClientSymmetricEngine.destroy(), it internally call AbstractSymmetricEngine.stop() in which thread.interrupt() is called for processInfo.getThread().

It happens that ..

1. ClientSymmetricEngine.destroy() is called at first
2. AbstractSymmetricEngine.stop() will be call
3. thread.interrupt() will be called
4. destroy() will call ((BasicDataSource)dataSource).close()
5. thread will throw org.jumpmind.exception.IoException: This thread was interrupted

Here, thread which got interrupted at step 3 is push thread with thread name "tnt3_rt-0000-push-1".

So, it happens that the push thread got interrupted at step-3 and dataSource.close() called before the push thread actually complete and got interrupt. This somehow leads to connection leaks for source database.

*One way to Fix:*
In AbstractSymmetricEngine.stop() after interrupting the thread, we should wait to join the thread.

thread.interrupt()
thread.join()

Thanks,
Nurali

Issue History

Date Modified Username Field Change
2017-01-25 05:57 nuralimca New Issue
2017-01-25 06:10 nuralimca Note Added: 0000960
2017-03-22 14:47 chenson Assigned To => maxwellpettit
2017-03-22 14:47 chenson Status new => assigned