[JAVA-1121] Socket Read timed out happens frequently Created: 21/Feb/14  Updated: 26/Feb/14  Resolved: 26/Feb/14

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: 2.11.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Trong Dao Le [X] Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

AWS AMI



 Description   

Even if the socket.setKeepAlive is true, the SocketException Read timed out still happens very frequently ( ~10 times a day.) I lowered the tcp_keepalive_time to 5 minutes but it doesn't seem to help.

How do we resolve this? Retry by ourselves? Could the driver retry automatically?



 Comments   
Comment by Trong Dao Le [X] [ 26/Feb/14 ]

Thanks, Jeff. Like I said, the request was received 10 minutes later at the server.
I'll close this and ask at the forum then.

Comment by Jeffrey Yemin [ 25/Feb/14 ]

From what you describe, this does not seem to be a problem with a specific socket, since as you say the response is, eventually, received. It's more likely a problem either in the network or in the database. So if you turn up logging in the database (e.g., -vv) when do you see the request being received at the server?

I should also mention that at this point this does not seem to be a bug in the Java driver, so it would be better to ask this type of question in our user forum (mongodb-user on Google groups).

Thanks,
Jeff

Comment by Trong Dao Le [X] [ 25/Feb/14 ]

I changed the socket timeout to -1 to check again. You are right, they seems to get through after 10 minutes (!!) What is your suggestion?

We can't manually retry, because it will use the same connection, right? Should the driver obtain a new connection from the pool and retry?

Comment by Jeffrey Yemin [ 25/Feb/14 ]

Do you have a reason to think that a stale connection would cause a read timeout? In my experience they usually result in an immediate SocketException of some sort.

Comment by Trong Dao Le [X] [ 24/Feb/14 ]

Hi Jeff,

My settings are:

  • SocketTimeout: 15s
  • KeepAlive: true
  • AutoConnectRetry: true
  • maxAutoConnectRetryTime: 5

All the timeout are Read operations. I check the profiler on the Mongo server, the request doesn't reach the server. It is either a network failure or a stale connection. It seems more probable that it is a stale connection.

Comment by Jeffrey Yemin [ 21/Feb/14 ]

keep-alive and read timeout are very different. What MongoClientOptions settings are you using when constructing your MongoClient instance?

Another thing to look at is which operations are timing out, and then determine why that's happening.

Generated at Thu Feb 08 08:53:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.