Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The listener can never be properly killed in Java from inside of a process #43

Open
yaronyg opened this issue Mar 27, 2014 · 0 comments

Comments

@yaronyg
Copy link
Contributor

yaronyg commented Mar 27, 2014

There appears to be a bug in TJWS that it doesn't properly shut itself down. Specifically when you think you have shut down the listener in fact TJWS keeps running, it just isn't listening for connections. But it's thread pool is still alive and still holding on to objects.

This results in a number of unfun problems.

Problem 1 - Leaking memory
Problem 2 - Hosting spurious threads
Problem 3 - Java objects from Couchbase stick around so things like change trackers (for pull replication) and file handles (for the SQL databases) stick around! This means amongst other things that you can't properly delete databases and you get all sorts of fun exceptions from the 'homeless' change trackers.

So as things now stand you can't really turn the listener off properly from inside a process in Java. This is a real nightmare for testing but it's also going to be a nightmare for production code. The reason is that one of the most sane things one can do for a long running service is turn it off every once in awhile and restart it. But you can't do that in any clean way in Java due to this bug. At best you will have to spawn the listener as a completely separate process and then kill that process. Yuck!

yaronyg added a commit to yaronyg/thali that referenced this issue Mar 27, 2014
JavaEktorpCreateClientBuilderTest - Needed to create a new temporary
directory on each test run because just shutting off the listener
doesn't appear to really shut it off (threads are still running) and
this appears to stop it from releasing file handles which means the
set up for the next test fails when it tries to delete the test databases.
couchbase/couchbase-lite-java-listener#43

Put in work around for timing bug in TJWS - couchbase/couchbase-lite-java-listener#40
@yaronyg yaronyg changed the title Is there any way to actually kill the listener? The listener can never be properly killed in Java from inside of a process Apr 2, 2014
yaronyg pushed a commit to yaronyg/thali that referenced this issue Apr 2, 2014
I changed our tests to create a single listener and re-use it for each test.
This isn't ideal since it's not clean. The ideal solution is to start a new
listener for each test. But there is a bug in TJWS that in Java when you
'shut it down' it actually leaves all of its threads running and they
do fun things like maintain locks on files and such. This is filed as
couchbase/couchbase-lite-java-listener#43
@jessliu jessliu added this to the Future milestone Apr 9, 2014
@hideki hideki added the backlog label Jun 23, 2016
@hideki hideki added icebox and removed backlog labels Oct 8, 2016
@hideki hideki removed this from the Future milestone Oct 8, 2016
@djpongh djpongh modified the milestones: 1.4.1, 1.4.2 Nov 28, 2017
@djpongh djpongh modified the milestones: 1.4.2, 1.4.x Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants