javaee / grizzly

Writing scalable server applications in the Java™ programming language has always been difficult. Before the advent of the Java New I/O API (NIO), thread management issues made it impossible for a server to scale to thousands of users. The Grizzly NIO framework has been designed to help developers to take advantage of the Java™ NIO API.
https://javaee.github.io/grizzly/
Other
222 stars 60 forks source link

Servlet request is executed twice (or n time) if timeout occurs while waiting for jdbc call #1956

Closed jGauravGupta closed 7 years ago

jGauravGupta commented 7 years ago

Description

Servlet request is executed twice (or n time) if timeout occurs while waiting for jdbc call

Expected Outcome

If a request takes too long to respond & timeout is reached then it shouldn't try to run the request second time.

Current Outcome

If 60 seconds request timeout is configured & the request has to run for 100 seconds, for example, the following happens:

If the jdbc call is replaced with sleep the second request is not dispatched, as expected.

rlubke commented 7 years ago

Please provide a test case demonstrating the issue.

rlubke commented 7 years ago

Closing this out as there has been no further response.

jGauravGupta commented 7 years ago

Hi @rlubke ,

Sorry for the delay, Please find the attached project with unit test case to reproduce the issue. In this unit test, If TransactionTimeout is enabled then service method is called 2 or 3 times after timeout so SQL query is also executed more than once. GrizzlyTxTimeoutTest.zip

Note : Query is using mysql SLEEP function for delay so mysql db connection is also required. H2 mysql mode is not working with SLEEP function.

jGauravGupta commented 7 years ago

Hi @rlubke ,

I tried the latest version 2.4.1 and 3.0-SNAPSHOT but I can still reproduce it. Is this issue fixed ? Thanks for looking into this !

rlubke commented 7 years ago

When running your test case, I see your log statement printed twice:

Executing query

Looking at the wire trace, I see the request executed twice on the wire. I don't believe there's an issue with Grizzy here. The client is retrying.

jGauravGupta commented 6 years ago

Here are the wire trace :

First Call : at org.glassfish.grizzly.http.server.TransactionTimeoutTest$1.service(TransactionTimeoutTest.java:39) at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:229) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:594) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:574) at java.lang.Thread.run(Thread.java:748)

Repeated Call : at org.glassfish.grizzly.http.server.TransactionTimeoutTest$1.service(TransactionTimeoutTest.java:39) at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:229) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:594) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:574) at java.lang.Thread.run(Thread.java:748)

Unfortunately H2 (MYSQL mode) does not support SLEEP function so you need a active MYSQL connection to reproduce it.