[JAVA-290] mongo driver should check whether socket still be available before use it? Created: 03/Mar/11 Updated: 19/Oct/16 Resolved: 14/Jun/11 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 2.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | phoenix | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
mongodb 1.8 |
||
| Issue Links: |
|
||||||||
| Description |
|
After the driver open a socket to mongos,we shutdown mongos and restart it,then write two record into mongos,the first one will lost. We had set autoConnectRetry to true. The driver check if ( _socket == null ) only,should it check _socket can works fine also? There are some exceptions: Caused by: com.mongodb.MongoException$Network: can't say something |
| Comments |
| Comment by Antoine Girbal [ 16/Aug/11 ] |
|
if you get the SocketTimeoutException it means that the server is not responding at all on that connection (not even RST). |
| Comment by Dion C [ 16/Aug/11 ] |
|
I'm seeing something similar in that the connection to the mongo server is closed (server log shows connection closed), but the java socket doesn't seem to realise it has been closed. Then attempting to do a find on a collection, results in "java.net.SocketTimeoutException: Read timed out" mongo 1.8.1 + java driver 2.6.3 |
| Comment by Scott Hernandez (Inactive) [ 14/Jun/11 ] |
|
If the socket is in a bad state it will throw an exception and we will create a new one. I believe we are doing a better job at tossing all those server's sockets in this case and this improvement has been included in 2.6.x: see There are always going to be errors on writes after a server has been restarted, or the connections have been lost. You can do a read first to flush the sockets for example. Doing this in the driver is no more efficient and isn't appropriate for writes. |
| Comment by Paul D. Walker [ 13/Jun/11 ] |
|
I'm seeing this problem too often. For some reason that I don't know why, the socket is getting closed with a "java.net.SocketException: Connection reset" error. (java driver 2.5.3 - server 1.8.1) |
| Comment by Andrew Louth [ 23/Mar/11 ] |
|
I'm interested in seeing a solution here because I need to handle cases where the mongo server has been restarted. In these cases, the server is available but saves will fail because the socket is no longer valid. |