Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WChos-0008No-UH for pgsql-jdbc@arkaria.postgresql.org; Mon, 10 Feb 2014 03:46:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WChor-0002a5-NQ for pgsql-jdbc@arkaria.postgresql.org; Mon, 10 Feb 2014 03:46:05 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WChom-0002Yf-HE for pgsql-jdbc@postgresql.org; Mon, 10 Feb 2014 03:46:03 +0000 Received: from [58.58.27.50] (helo=comp.highgo.com.cn) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WChoa-0002WL-3g for pgsql-jdbc@postgresql.org; Mon, 10 Feb 2014 03:45:55 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by comp.highgo.com.cn (Postfix) with ESMTP id 442826D884F1 for ; Mon, 10 Feb 2014 11:45:34 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=highgo.com.cn; h= content-type:content-type:subject:subject:to:mime-version :user-agent:from:from:date:date:message-id; s=dkim; t= 1392003920; x=1392867920; bh=RWpKODBW/Yv0LR/ML5dsq65v8gdIA5Jn4Pz N8OPKbH4=; b=lUKAdIToKdfy70ke8iJZYB4+aqWOoo+bYFlFE0bQ8ysd0uo7Ng5 bnA2o2RVIplaPpc4h6bSrbNseQlSWgRNOBo7eNcYIeWFfxt6hggFu6ClCELmtPUe f3gqY1Qgnuy8CjM6m4/WL4sFK4aE4/Bj7Hee+ksY9WCae2EBlKfO7Rdk= X-Virus-Scanned: amavisd-new at comp.highgo.com.cn Received: from comp.highgo.com.cn ([127.0.0.1]) by localhost (comp.highgo.com.cn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jIzUApg2XmXI for ; Mon, 10 Feb 2014 11:45:20 +0800 (CST) Received: from [192.168.100.61] (unknown [58.58.27.50]) by comp.highgo.com.cn (Postfix) with ESMTPSA id 639D76D88428 for ; Mon, 10 Feb 2014 11:45:20 +0800 (CST) Message-ID: <52F84B99.20800@highgo.com.cn> Date: Mon, 10 Feb 2014 11:46:33 +0800 From: zhangyuanchao User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: One question about setting query timeout. Content-Type: multipart/alternative; boundary="------------060306000709010207010004" X-Host-Lookup-Failed: Reverse DNS lookup failed for 58.58.27.50 (failed) X-Pg-Spam-Score: 2.4 (++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------060306000709010207010004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I have a question about setting query timeout by jdbc. When tested my application with Tomcat7.0 and loadrunner,my tomcat's configure file is like this: . After setting like above ,tomcat will call the jdbc's setQueryTimeout function and set the query timeout to 600seconds for each statement. Next,i start my test with 150 concurrency.After about 10 minutes later,i found the response time was much longer than before.At that moment,i found there were a lot of statement object in the heap memory of the JVM.And the JVM's gc could not clean these objects,because they were referenced by the TimerTask.So i read the source code of the jdbc and Timer class,i found the mainloop function of the Timer calss can cause the problem.This is the code of mainloop function in Timer class and i think the red colour text is that what cause the problem: private void mainLoop() { while (true) { try { TimerTask task; boolean taskFired; synchronized(queue) { // Wait for queue to become non-empty while (queue.isEmpty() && newTasksMayBeScheduled) queue.wait(); if (queue.isEmpty()) break; // Queue is empty and will forever remain; die // Queue nonempty; look at first evt and do the right thing long currentTime, executionTime; task = queue.getMin(); synchronized(task.lock) { if (task.state == TimerTask.CANCELLED) { queue.removeMin(); continue; // No action required, poll queue again } currentTime = System.currentTimeMillis(); executionTime = task.nextExecutionTime; if (taskFired = (executionTime<=currentTime)) { if (task.period == 0) { // Non-repeating, remove queue.removeMin(); task.state = TimerTask.EXECUTED; } else { // Repeating task, reschedule queue.rescheduleMin( task.period<0 ? currentTime - task.period : executionTime + task.period); } } } if (!taskFired) // Task hasn't yet fired; wait queue.wait(executionTime - currentTime); } if (taskFired) // Task fired; run it, holding no locks task.run(); } catch(InterruptedException e) { } } } } So,i want to ask if there is any solution for this problem. Thanks very much. --------------060306000709010207010004 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi,
    I have a question about setting query timeout by jdbc.
    When tested my application with Tomcat7.0 and loadrunner,my tomcat's configure file is like this:
<Resource ......
        jdbcInterceptors="QueryTimeoutInterceptor(queryTimeout=600)"
....../>.
    After setting like above ,tomcat will call the jdbc's setQueryTimeout function and set the query timeout to 600seconds for each statement.
Next,i start my test with 150 concurrency.After about 10 minutes later,i found the response time was much longer than before.At that moment,i found there were a lot of statement object in the heap memory of the JVM.And the JVM's gc could not clean these objects,because they were referenced by the TimerTask.So i read the source code of the jdbc and Timer class,i found the mainloop function of the Timer calss can cause the problem.This is the code of mainloop function in Timer class and i think the red colour text is that what cause the problem:

private void mainLoop() {
        while (true) {
            try {
                TimerTask task;
                boolean taskFired;
                synchronized(queue) {
                    // Wait for queue to become non-empty
                    while (queue.isEmpty() && newTasksMayBeScheduled)
                        queue.wait();
                    if (queue.isEmpty())
                        break; // Queue is empty and will forever remain; die

                    // Queue nonempty; look at first evt and do the right thing
                    long currentTime, executionTime;
                    task = queue.getMin();
                    synchronized(task.lock) {
                        if (task.state == TimerTask.CANCELLED) {
                            queue.removeMin();
                            continue;  // No action required, poll queue again
                        }
                        currentTime = System.currentTimeMillis();
                        executionTime = task.nextExecutionTime;
                        if (taskFired = (executionTime<=currentTime)) {
                            if (task.period == 0) { // Non-repeating, remove
                                queue.removeMin();
                                task.state = TimerTask.EXECUTED;
                            } else { // Repeating task, reschedule
                                queue.rescheduleMin(
                                  task.period<0 ? currentTime   - task.period
                                                : executionTime + task.period);
                            }
                        }
                    }
                    if (!taskFired) // Task hasn't yet fired; wait
                        queue.wait(executionTime - currentTime);

                }
                if (taskFired)  // Task fired; run it, holding no locks
                    task.run();
            } catch(InterruptedException e) {
            }
        }
    }
}
So,i want to ask if there is any solution for this problem.
Thanks very much.

   
--------------060306000709010207010004--