Using N1QL, Timeout

@Antx2207 -

Could you post the raw HTTP request? Just the querystring values (assuming you are doing a GET)…I would like to see what the client is sending the server.

-Jeff

@jmorris,

Could you please tell me how I could get the http request?

I try to use Fiddler but no working. I try to find some way to able but I cant.

@Antx2207

This should work:

              var uri = queryRequest.GetRequestUri(); 

-Jeff

@jmorris,

The uri:

.Net:

{http://127.0.0.1:8093/query?statement=SELECT q.* FROM default as q WHERE q.type = 'IwpCumulative' AND q.period = 5  AND q.sumActual < 400 AND q.category <> 'Budget'&timeout=1200000ms}

The result was successfully done but there was an exception with it.

Message:
The operation has timed out
StackTrace:
   at System.Net.HttpWebRequest.GetResponse()
   at Couchbase.N1QL.QueryClient.Get[T](Uri requestUri)

CBQ:

The result CBQ.
{
“category”: “Qty”,
“parent”: “Iwp::98”,
“period”: 5,
“sumActual”: 295,
“sumEarn”: 447,
“sumForecast”: 574,
“sumPlanned”: 550,
“sumValue”: 0,
“type”: “IwpCumulative”
},
.
.
.
.
.
.
{
“category”: “Cost”,
“parent”: “Iwp::9”,
“period”: 5,
“sumActual”: 384,
“sumEarn”: 594,
“sumForecast”: 477,
“sumPlanned”: 509,
“sumValue”: 0,
“type”: “IwpCumulative”
}
],
“status”: “success”,
“metrics”: {
“elapsedTime”: “25.5782182s”,
“executionTime”: “25.5772198s”,
“resultCount”: 215,
“resultSize”: 61368
}

@Antx2207 -

I see the problem; the server timeout is sent, but the client timeout (.NET stack) is using the default timeout specified by .NET. I created a Jira ticket for a fix: http://issues.couchbase.com/browse/NCBC-941

If you would like you can add yourself as a watcher and be alerted when the status changes.

-Jeff

@jmorris,

Thanks a lot!!

Hi @jmorris,

I saw that you solved the problem.

And the big question and I know that is very hurry ask this, but when is release from SDK 2.1.4.

http://issues.couchbase.com/browse/NCBC/fixforversion/12811#selectedTab=com.atlassian.jira.plugin.system.project%3Aversion-summary-panel

Because, this query throw timeout but at cbq does not.

select 
t.category,
t.period,
sum(t.sumActual) 
from 
default as q 
inner join default as p on keys q.parent 
inner join default as t on keys p.iwpCumulatives 
where
q.type = 'IwpCumulative' 
and q.period = 50
and q.sumActual > 0 
and q.category = 'Porcentaje' 
group by t.category,t.period
order by t.period,t.category;

Regards.

@Antx2207 -

Version 2.1.4 of the Couchbase .NET SDK is scheduled for Tuesday August 4th assuming all goes well with testing.

-Jeff

@jmorris,

Thanks a lot, I’ll be awaiting.

Regards.

Hi @jmorris,

Do you have any news about release?

Regards

@Antx2207 -

It’s going through QE; as soon as it passes I’ll push the packages to NuGet.

-Jeff

Hi Jeff,

Just wondering if NuGet package has been released already?
I’m currently testing and I’m facing same Timeout Issue when having > 1 mil documents with 2.1.4.0 version.

Thanks in advance for your kind support.

-Victor

Hey @victorvilla,

I don’t use this version yet, but I had another problem with timeout, but I did read the source and I saw that another error about timeout was this configuration:

I did set MaxAcquireIterationCount = int.MaxValue

BucketConfigs = new Dictionary<string, BucketConfiguration>
                                  {
                                    {"default", new BucketConfiguration
                                    {
                                      BucketName = "default",
                                      UseSsl = false,
                                      Password = "",
                                      DefaultOperationLifespan = 2000,
                                      PoolConfiguration = new PoolConfiguration
                                      {
                                        MaxSize = 10,
                                        MinSize = 5,
                                        SendTimeout = int.MaxValue,
                                        ConnectTimeout=int.MaxValue,
                                        MaxAcquireIterationCount = int.MaxValue
                                      }
                                    }}}
            };

Regards.

@victorvilla -

2.1.4 is available from NuGet: https://www.nuget.org/packages/CouchbaseNetClient/2.1.4

-Jeff

Thanks for the hint @Antx2207 !!
I have actually changed it too but I still see same timeout exception

((System.Net.WebException)(((Couchbase.N1QL.QueryResult<object>)(result)).Exception))
"The operation has timed out"
"at System.Net.HttpWebRequest.GetResponse()\r\n   at Couchbase.N1QL.QueryClient.Get[T](Uri requestUri)"  

It started happening as you indicated when going above 1’000,000 documents even with new version 2.1.4 which I have already updated and if I use any conditions in a WHERE statement.

The way I’m creating my request is:

var  TimeSpan timeout = new TimeSpan(0, 30, 0);
var queryRequest = new QueryRequest()
                                   .Statement("SELECT * FROM `TestBucket` WHERE device_id=$1") 
                                   .AddPositionalParameter("2362098967") 
                                   .Timeout(timeout);

Do you have any other suggestions?

Thanks in advance for your help.

-Victor

@victorvilla -

Use the ClientConfiguration.QueryRequestTimeout since the timeout is on the client-side; the QueryRequest.Timeout(…) is the server timeout so that the query doesn’t run indefinitely.

In a later release (2.2.0) the two values will be synced, but not in 2.1.4.

MaxAcquireIterationCount is for tuning the time the SDK will wait for a connection while doing a Key/Value request; it does not have any affect on the N1QL or View queries.

-Jeff

Thanks @jmorris !!
It looks like we’re getting there… However I now get the following error :

{Couchbase.N1QL.Error}	Couchbase.N1QL.Error
Code: 5000
"GSI scan error - cause: Index scan timed out "

Any ideas?

Also, do you know if there are any options for performance tunning when using N1QL?
It looks like it is just too much effort to lookup trough 1’000,000 documents, but in this POC we will be aiming to actually search trough at least 1’000,000,000 docs to measure performance.

@victorvilla -

So, the first error you were getting when this thread started was a client timeout, now you are getting a server timeout. Are the client and server timeouts the same? If not, make them the same or extend the timeout(s).

Maybe @colm or @geraldss can help out here?

-Jeff

Great thanks @jmorris !!!
You were totally right, timeouts on client and server were different, I’ve sync them and now it seems that timeout issue is gone !!!

However it returned the document I was looking for in 4 minutes after looking through 1’000,000 docs, so I go back to my previous question, is there any documentation on how to tune this?

@victorvilla,

Do you try to create Index?

http://docs.couchbase.com/4.0/n1ql/n1ql-language-reference/createindex.html

Maybe you could see this:

Regards