Re: [Simpleweb-Support] FIX: Simple stops responding
Brought to you by:
niallg
From: Andrew M. <and...@ya...> - 2005-08-04 17:29:41
|
Ok, I'm sure it's an absolutely horrible implementation but this is what I did (keep in mind I'm not sure this is the same problem, but it seems to have the same symptoms). public class BlockingQueue { private Link first; private Link last; private int maxWait = 100; public BlockingQueue() {} public BlockingQueue(int wait) { maxWait = wait; } public void add(Object o) { if (o == null) throw new NullPointerException(); synchronized(this) { if (first == null) { first = new Link(o); first.timeout = -1; last = first; } else { last.next = new Link(o); last.next.timeout = -1; } notify(); } } public void add(Object o, long wait) { if (o == null) throw new NullPointerException(); synchronized(this) { if (first == null) { first = new Link(o); first.timeout = System.currentTimeMillis() + Math.min(wait,maxWait); last = first; } else { last.next = new Link(o); last.next.timeout = System.currentTimeMillis() + Math.min(wait,maxWait); } notify(); } } public Object getNext() throws InterruptedException { synchronized (this) { while (first == null) wait(); sleepUntil(first.timeout); Object o = first.value; first = first.next; return o; } } public void clear() { first = null; last = null; } private class Link { public Link next; public Object value; public long timeout; public Link(Object value) {this.value = value;} } protected void sleepUntil(long awaken) throws InterruptedException { long time = System.currentTimeMillis(); long sleep = awaken - time; if(sleep <= 0) return; Thread.sleep(sleep); } } Niall Gallagher wrote: >Hi Andrew, > >I would like to see your implementation! I have >searched through all classes in the >simple.util.schedule package and also tested them, and >I had not found errors or deadlock situations? Perhaps >I can learn somthing from your implementation that I >have overlooked. I would certainly appreciate it! > >Niall > >--- Andrew Madigan <and...@ya...> wrote: > > > >>Alright I've taken another look at the the code I >>used, this is what >>I've figured out: >>- I assumed that simple used >>util.schedule.SchedulerQueue and that this >>was causing problems >>- I replaced the use of this class (still trying to >>find where) with a >>different implementation that used a simpler method >>of blocking >>and did not use arrays >>- As I said I am no threading expert so there are >>probably flaws in my >>queue implementation, but I have never had problems >>with it and I use it >>in the application that I run on top of simple as >>well. >> >>If you would like me to post the code for the queue >>I will just let me know. >> >>Jorge CAMPOS wrote: >> >> >> >>>Hi everybody! >>> >>>>From our tests with our application, it seems that >>> >>> >>Simple hangs only when >> >> >>>using at least 35 threads in parallel (we're >>> >>> >>testing in a 4Way Xeon with HT >> >> >>>running SuSE SLES 9.0 and JDK 1.5.0_04). From the >>> >>> >>thread dump and some >> >> >>>printlns in the code it seems that one thread >>> >>> >>(dequeuer) blocks because >> >> >>>there are no more requests to be processed. After >>> >>> >>that everything starts >> >> >>>piling up (all the dequeuers wait for the first one >>> >>> >>and the enqueuers too). >> >> >>>I know it sound a bit weird, but it could be >>> >>> >>related to the locking queue >> >> >>>implementation. >>> >>>I've tried to reproduce the problem using the demo >>> >>> >>server and I didn't >> >> >>>succeed. I guess the context is different (to >>> >>> >>simulate some load I've put >> >> >>>one sleep and some printlns). This made me look >>> >>> >>again at our thread dump... >> >> >>>and I can't see anything related to our application >>> >>> >>(it seems that Simple >> >> >>>blocks within its code). >>> >>>One question Andrew: what are the specs of your >>> >>> >>machine? >> >> >>>I'm asking this, because I've seen some locking >>> >>> >>problems in applications >> >> >>>running with HyperThreading ON. >>> >>>We will test the application running with >>> >>> >>HyperThreading off and in another >> >> >>>machine to see if we can reproduce the problem. >>> >>>All your support is greatly appreciated. >>> >>>Ah, one more thing. Since in our thread dump it >>> >>> >>seems all the threads are >> >> >>>still alive, I don't think this particular case >>> >>> >>relates to a out of memory >> >> >>>exception (also there are no exceptions in the >>> >>> >>logs) >> >> >>>Jorge >>> >>>-----Original Message----- >>>From: sim...@li... >>> >>> >>[mailto:sim...@li...]On >>Behalf Of Niall >> >> >>>Gallagher >>>Sent: Wednesday, August 03, 2005 10:21 AM >>>To: sim...@li... >>>Subject: Re: [Simpleweb-Support] FIX: Simple stops >>> >>> >>responding >> >> >>>Hi, >>> >>>I have taken note of the last two comments with >>> >>> >>regard >> >> >>>to the server freezing! In response to the queue >>>implementation, I think that the implementation of >>> >>> >>the >> >> >>>Scheduler, ObjectQueue, and ProcessQueue involved >>> >>> >>in >> >> >>>dispatching requests is fine. There are no problems >>>here. >>> >>>However, the simple.http.connect implementation may >>> >>> >>be >> >> >>>at fault, and I have no doubt whatsoever that the >>>java.lang.OutOfMemory error will cause the server >>> >>> >>to >> >> >>>stop responding under very heavy load. >>> >>>I have uploaded my test framework for anyone >>> >>> >>wishing >> >> >>>to use it to see if it will freeze their server. >>> >>> >>If >> >> >>>it does then great! let me know what happened. >>>However, I have put through well over a 100 million >>>requests using my test framework today alone and, >>> >>> >>with >> >> >>>the catch(Throwable) amendments there is no >>> >>> >>deadlock, >> >> >>>not even a lost thread. >>> >>>The test framework can be downloaded at >>>http://simpleweb.sf.net/simple-test.tar.gz. >>> >>>So, in conclusion, the application is thread safe >>> >>> >>and >> >> >>>working properly with catch(Throwable) amendments. >>>However, the TCP related issues have not been >>> >>> >>thought >> >> >>>out carefully! And I believe the >>> >>> >>simple.http.connect >> >> >>>package needs to be reworked! I will release all >>> >>> >>the >> >> >>>bug fixes as soon as I am convinced everything is >>>working. >>> >>>Thanks for the bug reports, if anyone thinks the >>>freeze is related to somthing else please let me >>> >>> >>know >> >> >>>so that I can explore it! >>> >>>Niall >>> >>> >>>Niall Gallagher >>> >>>__________________________________________________ >>>Do You Yahoo!? >>>Tired of spam? Yahoo! Mail has the best spam >>> >>> >>protection around >> >> >>>http://mail.yahoo.com >>> >>> >>> >>> >>------------------------------------------------------- >> >> >>>SF.Net email is sponsored by: Discover Easy Linux >>> >>> >>Migration Strategies >>>from IBM. Find simple to follow Roadmaps, >>straightforward articles, >> >> >>>informative Webcasts and more! Get everything you >>> >>> >>need to get up to >> >> >>>speed, fast. >>> >>> >http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > > >>>_______________________________________________ >>>Simpleweb-Support mailing list >>>Sim...@li... >>> >>> >>https://lists.sourceforge.net/lists/listinfo/simpleweb-support >> >> >>> >>> >>> >>------------------------------------------------------- >> >> >>>SF.Net email is Sponsored by the Better Software >>> >>> >>Conference & EXPO >> >> >>>September 19-22, 2005 * San Francisco, CA * >>> >>> >>Development Lifecycle Practices >> >> >>>Agile & Plan-Driven Development * Managing Projects >>> >>> >>& Teams * Testing & QA >> >> >>>Security * Process Improvement & Measurement * >>> >>> >>http://www.sqe.com/bsce5sf >> >> >>>_______________________________________________ >>>Simpleweb-Support mailing list >>>Sim...@li... >>> >>> >>https://lists.sourceforge.net/lists/listinfo/simpleweb-support >> >> >>> >>> >>> >>> >> >> >> >> >------------------------------------------------------- > > >>SF.Net email is Sponsored by the Better Software >>Conference & EXPO >>September 19-22, 2005 * San Francisco, CA * >>Development Lifecycle Practices >>Agile & Plan-Driven Development * Managing Projects >>& Teams * Testing & QA >>Security * Process Improvement & Measurement * >>http://www.sqe.com/bsce5sf >>_______________________________________________ >>Simpleweb-Support mailing list >>Sim...@li... >> >> >> >https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > >Niall Gallagher > > > >____________________________________________________ >Start your day with Yahoo! - make it your home page >http://www.yahoo.com/r/hs > > > >------------------------------------------------------- >SF.Net email is Sponsored by the Better Software Conference & EXPO >September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices >Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA >Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf >_______________________________________________ >Simpleweb-Support mailing list >Sim...@li... >https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > |