I can’t able to share my code, logs, etc. directly as I am working on Virtual Desktop and Couchbase community forum is blocked from inside that network. So pardon me if there is any mistake.
I am running a n1ql query through java as below.
Statement statement = Select.select(“*”).from(“my_url”).where(Expression.x(“user”).eq(“$user”).and(Expression.x(“url”).eq(“$url”))).limit(1);
JsonObject placeholderValues = JsonObject.create().put(“user”,myRequest.getUsername()).put(“url”,myRequest.getUrl());
N1qlQuery query = N1qlQuery.parameterized(statement,placeholderValues);
N1qlQueryResult results = couchbaseBucket.query(query); //TimeoutException
final Iterator result = results.iterator();
if(result.hasNext()) {
ObjectMapper objectMapper = new ObjectMapper();
MyURL myURL = null;
try {
myURL = objectMapper.readValue(result.next().value().get(“my_url”).toString(),MyURL.class); //TranscodingException
} catch (IOException e) {
} catch(TranscodingException e) {
e.printStackTrace();
}
}
}
If url
does not exist( against the user
) in bucket my_url
then I am inserting an object containing the url
as below
EntityDocument doc = EntityDocument.create(myURL);
couchbaseBucket.repository().insert(doc);
My Couchbase configuration in spring is as follow
@Configuration
@EnableCouchbaseRepositories(basePackages = {“com.my.model”})
public class MyCouchbaseConfig extends AbstarctCouchbaseConfiguration {
@Override
protected List getBootStrapHosts(){
return Collections.singletonList(“xxxx,yyyy”);
}
@Override
protected String getBucketName(){
return “my_url”;
}
@Override
protected String getBucketPassword(){
return “my_pass”;
}
@Override
protected CouchbaseEnvironment getEnvironment(){
return DefaultCouchbaseEnvironment.builder().connectTimeout(10000).computationPoolSize(15).build();
}
}
Now when I am executing load test using Jmeter, initially for around 2 min everything works fine. But then it started throughing exception with message like TranscodingException: Error deserilizing row value from bytes to JsonObject
(check above comment for line details). Then again it started working fine for a while and at the end of load test it started throughing RuntimeException: java.util.concurrent.TimeoutException
(check above comment for line details).
Load test with 200 concurrent user for 500 rounds i.e. 1Lakh sample, getting 30% to 50% failure.
Relevent indexing details below
CREATE INDEX ‘url_user_index’ ON ‘my_url’(‘url’,‘user’) USING GSI
Tested with spring-data-couchbase-2.2.0.RELEASE.jar
+ java-client-2.2.7.jar
and with spring-data-couchbase-2.2.0.RELEASE.jar
+ COUCHBASE SDK 2.2.8/2.2.7
. But nothing works for me.
Couchbase server 4.1.1 - 5914.