the first query always fails after a CouchDbConnector created #91

Open
yblee85 opened this Issue Oct 25, 2012 · 4 comments

Comments

Projects
None yet
2 participants

yblee85 commented Oct 25, 2012

I'm using ektorp-1.2.1.

I created a dbInstacne and using several CouchDbConnectors with this CouchDbInstance.

for the first few times, it works fine.
but at one point, the first query fails after a CouchDbConnector created.

here's the code summary


HttpClient httpClient = new StdHttpClient.Builder().connectionTimeout(0).socketTimeout(0).url(address).build();

CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);

CouchDbConnector dbCon = new StdCouchDbConnector("db_A", dbInstance);
//using dbCon for query.... (it works)

dbCon = new StdCouchDbConnector("db_B", dbInstance);
//using dbCon for query.... (it works)

dbCon = new StdCouchDbConnector("db_C", dbInstance);
//using dbCon for query.... (it works)

// i used same dbCon value as different connectors with a same dbInstance.

//FIXME : at some point, it won't work
dbCon = new StdCouchDbConnector("db_A", dbInstance);
ViewQuery query = new ViewQuery().designDocId("_design/A").viewName("viewName_A").key("keyA");
try {
ViewResult result = dbCon.queryView(query); // it throws an "SocketTimeoutException: Read timed out" exception.
} catch(Exception e){}

ViewResult result = dbCon.queryView(query); // now it works...


should i created different CouchDbInstance for different db?
or is this a bug?

Owner

helun commented Oct 26, 2012

Hi,

Try setting connection timeout and socket timeout to something greater than 0, such as 500.

/Henrik

25 okt 2012 kl. 23:13 skrev yblee85 notifications@github.com:

I'm using ektorp-1.2.1.

I created a dbInstacne and using several CouchDbConnectors with this CouchDbInstance.

for the first few times, it works fine.
but at one point, the first query fails after a CouchDbConnector created.

here's the code summary

HttpClient httpClient = new StdHttpClient.Builder().connectionTimeout(0).socketTimeout(0).url(address).build();

CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);

CouchDbConnector dbCon = new StdCouchDbConnector("db_A", dbInstance);
//using dbCon for query.... (it works)

dbCon = new StdCouchDbConnector("db_B", dbInstance);
//using dbCon for query.... (it works)

dbCon = new StdCouchDbConnector("db_C", dbInstance);
//using dbCon for query.... (it works)

// i used same dbCon value as different connectors with a same dbInstance.

dbCon = new StdCouchDbConnector("db_A", dbInstance);
ViewQuery query = new ViewQuery().designDocId("_design/A").viewName("viewName_A").key("keyA");
try {
ViewResult result = dbCon.queryView(query); // it throws an "SocketTimeoutException: Read timed out" exception.
} catch(Exception e){}

ViewResult result = dbCon.queryView(query); // now it works...

should i created different CouchDbInstance for different db?
or is this a bug?


Reply to this email directly or view it on GitHub.

yblee85 commented Oct 26, 2012

Hi, thanks for quick reply.
I tried it but it didn't work.

i found an interesting thing,
so above queries i filtered replicate documents from remote db to local db
and when those documents are not that many like a couple of hundreds document, that issued line works.
but when those documents are pretty big, like.. 5000 docs, that issue happens.

i was wondering this situation has something to do with the issue.
i'll try to figure it out and keep you posted.

thanks

Owner

helun commented Oct 26, 2012

A view is generated the first time you hit it, that is your problem.
The timeout happens before the view generation has finished.

You will have investigate why your view is so slow, 5000 docs is not really any significant number at all.

Here is a starting point for you:
http://wiki.apache.org/couchdb/Performance#View_generation

/Henrik

26 okt 2012 kl. 15:58 skrev yblee85 notifications@github.com:

Hi, thanks for quick reply.
I tried it but it didn't work.

i found an interesting thing,
so above queries i filtered replicate documents from remote db to local db
and when those documents are not that many like a couple of hundreds document, that issued line works.
but when those documents are pretty big, like.. 5000 docs, that issue happens.

i was wondering this situation has something to do with the issue.
i'll try to figure it out and keep you posted.

thanks


Reply to this email directly or view it on GitHub.

yblee85 commented Oct 29, 2012

that link helped me a lot. thanks helun.
but the view was already generated at that time.
and even simply "dbCon.get(JsonNode.class, document_id)" also throws readtimeout exception.
i'm sorry that i can't attach code due to our security stuff.
i'll dig in more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment