[CDRIVER-25] Way to set operation timeout. Created: 15/Nov/10  Updated: 19/Oct/16  Resolved: 07/Jul/11

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 0.4

Type: Improvement Priority: Major - P3
Reporter: Dilip Vaidya Assignee: Kyle Banker
Resolution: Done Votes: 7
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS: Linux, 32 and 64 bit.



 Description   

Hello there,

When doing MongoDB tests, I found out that if there is no response from MongoDB for some reason to a query, request get stuck there for the unknown timing.
I am using MongoDB's 'C' driver to handle HTTP requests and here need is that user should get response within second( rather milliseconds).

When HTTP request comes for any CRUD(create, insert, update, Delete) operation, there should be a way to specify a timeout period for a request, so that if there is any error like network issue etc. and request is taking more time than the req_timeout_period, then request should not get stuck there and should return error something like "MongoDB request timed out".

It helps me to respond to HTTP request within desired time window. If HTTP request is just waiting for MongoDB to respond, web page @ the user (browser) will be in loading state for that much time. If this handled by the 'C' driver in appropriate way, then I will be able to respond to HTTP_Request in appropriate manner.

The way I want it is something like this:

set_req_timeout(int in_sec);
OR
set_req_timeout(int in_milli_sec);

// operation request send to MongoDB
TRY {
send( operation, massage );
}
CATCH ( MongoDB_Req_TimeOut ) {
cancel request to MongoDB; // so that this request wont keep trying for response anymore
return MongoDB_Req_TimeOut;
}



 Comments   
Comment by auto [ 07/Jul/11 ]

Author:

{u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}

Message: CDRIVER-25 added test for timeouts
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/5ef4012866cb4bc01a4cad4fb1cbf323441e619f

Comment by auto [ 07/Jul/11 ]

Author:

{u'login': u'banker', u'name': u'Kyle Banker', u'email': u'kylebanker@gmail.com'}

Message: CDRIVER-25 test operation timeout
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/c1afbb69dd1a1aceca7851a71368d49520c7d4a2

Generated at Wed Feb 07 21:08:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.