Operation is not valid due to the current state of the object.

724 views
Skip to first unread message

Kyle Heon

unread,
Jun 6, 2013, 8:17:19 AM6/6/13
to couchba...@googlegroups.com
We have a task (C#/ASP.NET) that connects to our Couchbase server for data that is reported on. We are finding that out of the gate, after an iisreset the task runs to completion without any issues but on subsequent executions it fails. The logs indicate the following issue:

System.Exception: PageVisitLogger::GetPageVisits return PageVisitRepository.GetPageVisits ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Couchbase.CouchbaseViewHandler.GetResponse(IDictionary`2 viewParams)
   at Couchbase.CouchbaseViewHandler.<TransformResults>d__0`1.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at OurAssembly.Framework.Tracking.PageVisitLogger.GetPageVisits(String userId, Boolean refresh)
   --- End of inner exception stack trace ---

We are using the following setup for creating the Couchbase client (and I've verified that it isn't the client that has somehow gone null):

public CouchbaseClient CouchbaseClient
{
    get
    {
        if (null != HttpContext.Current)
        {
            var ctx = HttpContext.Current.ApplicationInstance.Context;

            if (!ctx.Items.Contains(CouchbaseClientKey))
            {
                ctx.Items[CouchbaseClientKey] = new CouchbaseClient();
            }

            var client = ctx.Items[CouchbaseClientKey] as CouchbaseClient;
            if (null != client) return client;
        }

        return new CouchbaseClient();
    }
}

 The code calling Coubhase looks like this:

public IEnumerable<PageVisit> GetPageVisits(string userId)
{
    var visits =
        this.CouchbaseClient.GetView("digital_campus_pagevisits", "digital_campus_pagevisits")
            .Key(userId)
            .Stale(StaleMode.False);
    return visits.Select(visit => Get(visit.ItemId));
}

I'm at a loss now to figure out what is causing this error and could use some assistance because obviously restarting IIS before this task runs is out of the question.

-K 

Perry Krug

unread,
Jun 6, 2013, 10:24:11 AM6/6/13
to couchba...@googlegroups.com
Kyle, I saw something similar to this in another environment so may very well be a bug that we need to address.

A few things:
-Can you implement logging on the client and send that over?
-Can you try with "stalemode.true" instead of false?

--
Couchbase 2.0 is Here!: http://www.couchbase.com/download
Couchbase 2.0 Learn: http://www.couchbase.com/learn
Couchbase Forums: http://www.couchbase.com/forums
---
You received this message because you are subscribed to the Google Groups "Couchbase Team 8091" group.
To unsubscribe from this group and stop receiving emails from it, send an email to couchbase-809...@googlegroups.com.
To post to this group, send email to couchba...@googlegroups.com.
Visit this group at http://groups.google.com/group/couchbase-8091?hl=en.
To view this discussion on the web visit https://groups.google.com/d/msgid/couchbase-8091/bab69758-fe43-41b6-ac0d-7ccbc3167d37%40googlegroups.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kyle Heon

unread,
Jun 6, 2013, 10:26:56 AM6/6/13
to couchba...@googlegroups.com
Perry,

This issue was happening last week, I just added the Stale property so it's not that. I have actually identified that this issue is in SDK 1.2.6. I just reverted back to our previous build (original 1.2 I believe) and I don't see this issue.

What I'm trying to do now is determine if it's the SDK or the removal of the Hammock HttpClient from configuration.

-K

Perry Krug

unread,
Jun 6, 2013, 10:27:58 AM6/6/13
to couchba...@googlegroups.com
Thanks for that information Kyle.  Logs would still be helpful from 1.2.6 so we can help identify the issue as well.

-K

--
Couchbase 2.0 is Here!: http://www.couchbase.com/download
Couchbase 2.0 Learn: http://www.couchbase.com/learn
Couchbase Forums: http://www.couchbase.com/forums
---
You received this message because you are subscribed to the Google Groups "Couchbase Team 8091" group.
To unsubscribe from this group and stop receiving emails from it, send an email to couchbase-809...@googlegroups.com.
To post to this group, send email to couchba...@googlegroups.com.
Visit this group at http://groups.google.com/group/couchbase-8091?hl=en.

Kyle Heon

unread,
Jun 6, 2013, 10:36:52 AM6/6/13
to couchba...@googlegroups.com
Perry,

I'll try but I'm under the pressure of an already late deadline. If I can't get this configured quickly I'm going to have to revert to our previous SDK build. I'll do what I can, maybe even get you this data when things aren't so crazy. Obviously I want to be running with the latest SDK so I'd like to get to the bottom of this...

-K

Perry Krug

unread,
Jun 6, 2013, 10:40:37 AM6/6/13
to couchba...@googlegroups.com
Understand completely Kyle.  I would say that having logging configured and easily enabled in your application and development environments would be a good practice overall moving forward.




-K

--
Couchbase 2.0 is Here!: http://www.couchbase.com/download
Couchbase 2.0 Learn: http://www.couchbase.com/learn
Couchbase Forums: http://www.couchbase.com/forums
---
You received this message because you are subscribed to the Google Groups "Couchbase Team 8091" group.
To unsubscribe from this group and stop receiving emails from it, send an email to couchbase-809...@googlegroups.com.
To post to this group, send email to couchba...@googlegroups.com.
Visit this group at http://groups.google.com/group/couchbase-8091?hl=en.

Kyle Heon

unread,
Jun 6, 2013, 11:10:24 AM6/6/13
to couchba...@googlegroups.com
Perry,

I reverted back to the latest 1.2.6 and added logging as you requested. I'm attaching the log file, as you can see there are hundreds of the same error, those all occur after the first run through. Meaning I load the page once and everything works, if I reload the page there are errors.

If you know what the issue is and have a workaround for me I'll try and hold off on doing a build in the hopes that I can get this resolved and continue to use 1.2.6 otherwise I'm going to have to go back to 1.2.0.

-K
couchbase.log

Perry Krug

unread,
Jun 6, 2013, 11:14:32 AM6/6/13
to couchba...@googlegroups.com
Thank you Kyle.  Is that the entire log file?  It seems to be missing a bit of context...and/or can you set the log level to something more like INFO or DEBUG?




-K

--
Couchbase 2.0 is Here!: http://www.couchbase.com/download
Couchbase 2.0 Learn: http://www.couchbase.com/learn
Couchbase Forums: http://www.couchbase.com/forums
---
You received this message because you are subscribed to the Google Groups "Couchbase Team 8091" group.
To unsubscribe from this group and stop receiving emails from it, send an email to couchbase-809...@googlegroups.com.
To post to this group, send email to couchba...@googlegroups.com.
Visit this group at http://groups.google.com/group/couchbase-8091?hl=en.

Kyle Heon

unread,
Jun 6, 2013, 11:29:27 AM6/6/13
to couchba...@googlegroups.com
Perry,

Yes, that was the full log and was INFO. I updated configuration so that it wrote out DEBUG and that provides a lot more data for you. I've attached the log file (zipped). You should be able to see where things go off the rails.

-K
couchbase.zip

Perry Krug

unread,
Jun 6, 2013, 11:30:29 AM6/6/13
to couchba...@googlegroups.com
Great, thanks Kyle.

-K

--
Couchbase 2.0 is Here!: http://www.couchbase.com/download
Couchbase 2.0 Learn: http://www.couchbase.com/learn
Couchbase Forums: http://www.couchbase.com/forums
---
You received this message because you are subscribed to the Google Groups "Couchbase Team 8091" group.
To unsubscribe from this group and stop receiving emails from it, send an email to couchbase-809...@googlegroups.com.
To post to this group, send email to couchba...@googlegroups.com.
Visit this group at http://groups.google.com/group/couchbase-8091?hl=en.

Kyle Heon

unread,
Jun 6, 2013, 11:57:11 AM6/6/13
to couchba...@googlegroups.com
Perry,

You are welcome, I hope that I'm able to help you solve this issue if it is indeed an issue. I have to revert to the 1.2.0 SDK for now and do another build to our testing environment so users can be testing the site. I'm going to try and continue working through this with you after that because I'd prefer to ship with SDK 1.2.6 connected to Couchbase 2.0.1.

I'm attaching a log file from two back to back runs with the 1.2.0 SDK in the hopes that will help as well. It's twice the size which makes sense as the task ran to completion twice.

Let me know what you find.

-K
couchbase-1.2.0-sdk.zip

Kyle Heon

unread,
Jun 7, 2013, 3:22:29 PM6/7/13
to couchba...@googlegroups.com
Did you find anything of interest in the logs Perry? Anything I can do to work around this issue and continue to use 1.2.6?

-K

Kyle Heon

unread,
Jul 9, 2013, 7:54:33 AM7/9/13
to couchba...@googlegroups.com
Hey Perry,

Any update on your findings from the diagnostics I provided? We've launched our 2.1 release using the old 1.2.0 SDK due to the issues we ran into with 1.2.6. We have started development on our new 2.2 release (scheduled for a mid-October launch) and I'd love to be able to update to the latest .NET SDK as part of this upcoming release.

Thanks again for your assistance.

-K

Tugdual

unread,
Jul 10, 2013, 3:33:13 AM7/10/13
to couchba...@googlegroups.com
Hello Kyle,

So you have 2 different issues:

- with 1.2.6 : 
----
System.Exception: PageVisitLogger::GetPageVisits return PageVisitRepository.GetPageVisits ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Couchbase.CouchbaseViewHandler.GetResponse(IDictionary`2 viewParams)
   at Couchbase.CouchbaseViewHandler.<TransformResults>d__0`1.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at OurAssembly.Framework.Tracking.PageVisitLogger.GetPageVisits(String userId, Boolean refresh)
   --- End of inner exception stack trace ---
-----



- with 1.2.0 : cannot execute view:
---
2013-06-06 11:25:07.6744|DEBUG|Couchbase.MessageStreamListener|HB: Node 'http://localhost:8091/pools/default' is OK
2013-06-06 11:25:13.4970|INFO|Couchbase.CouchbasePool|Received new configuration.
2013-06-06 11:25:13.4970|INFO|Couchbase.CouchbasePool|Has vbucket. Server count: 1
2013-06-06 11:25:13.4970|DEBUG|Couchbase.CouchbasePool|Found address 127.0.0.1 for 127.0.0.1
2013-06-06 11:25:13.4970|DEBUG|Couchbase.CouchbasePool|Using address 127.0.0.1 for 127.0.0.1
2013-06-06 11:25:13.4970|ERROR|Couchbase.CouchbasePool|Failed to initialize the pool.
2013-06-06 11:25:13.4970|DEBUG|Couchbase.CouchbaseClient|No working nodes found. Unable to execute view query
2013-06-06 11:25:13.4970|WARN|Couchbase.CouchbaseViewHandler|View Couchbase.CouchbaseViewHandler was mapped to a dead node, failing.
----

Do you see anything on the Couchabse Server log itself? it looks like your server is going down/not visible for a while...


Have you tried to use a remote server/cluster from your application?

Regards
Tug
@tgrall

Kyle Heon

unread,
Sep 9, 2013, 8:42:42 AM9/9/13
to couchba...@googlegroups.com
Tugdual,

Sorry, somehow I missed this reply from you. I just noticed this morning that there is a new Couchbase .NET SDK (1.2.7) and the release notes (http://www.couchbase.com/docs/couchbase-sdk-net-1.2/couchbase-sdk-net-rn_1-2-7a.html) seem to indicate that a fix for our issue with 1.2.6 was included (NCBC-278: Lock WebClient when getting WebRequest). Can anyone at Couchbase confirm this?

-K
Reply all
Reply to author
Forward
0 new messages