AggressivelyCache not working correctly in R4

60 views
Skip to first unread message

Marcelo Volmaro

unread,
Oct 11, 2017, 9:58:02 AM10/11/17
to RavenDB - 2nd generation document database
I have an app that it is currently working, and I tried to take the advantage of AggressivelyCache over one entity so I don't have to maintain my own cache.
So, where I read the entity I simply wrapped the Load operation with using (Session.Advanced.DocumentStore.AggressivelyCache())... and that's it (at least that's what I understand from the docs).

Now, this is working until I need to edit that entity. When I edit it, none of the changes are reflected on the client, but they are updated on the server. It doesn't matter if I refresh the page X times, I'm always getting stale content. Even worsts, if I try to edit again that entity I can't save it anymore because I'm getting the error "Document 100641491089330176 has change vector A:48-Q9hd8zs2lkaj41pL43OsnQ, but Put was called with change vector A:43-Q9hd8zs2lkaj41pL43OsnQ. Optimistic concurrency violation, transaction will be aborted." (that of course makes sense, as the document in the DB is not the same that I have on the client)...

Is this a bug, or something that I'm doing wrong?

Oren Eini (Ayende Rahien)

unread,
Oct 11, 2017, 9:59:22 AM10/11/17
to ravendb
This looks like a bug. 
Can you send us a way to reproduce this?

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marcelo Volmaro

unread,
Oct 11, 2017, 10:14:05 AM10/11/17
to RavenDB - 2nd generation document database
This is happening on an app, that while the above part is quite simple (is a simple abm), the rest it is not and depends on several internal nuget packages...
I think that you should be able to do a repro since the only change I introduced was the wrapped load... I removed it now and everything went back to normal...
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Oct 11, 2017, 10:40:04 AM10/11/17
to ravendb
I cannot reproduce, see the code below?
I start the client, hit ENTER a few times, and see that we don't have an increase in the number of the documents calls.
Then I manually modify the document on the server and hit ENTER again.
The document update shows up.

 static void Main(string[] args)
 {
     var documentStore = new DocumentStore
     {
         Urls = new[] {"http://4.live-test.ravendb.net"},
         Database = "Test"
     };
     documentStore.Initialize();

     while (true)
     {
         using (var s = documentStore.OpenSession())
         {
             dynamic load;
             using (documentStore.AggressivelyCache())
             {
                 load = s.Load<dynamic>("users/1");
             }
             Console.WriteLine(load.Name);
             Console.WriteLine(documentStore.GetRequestExecutor().NumberOfServerRequests);
         }
         Console.ReadLine();
     }
 }



To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Oct 11, 2017, 1:35:37 PM10/11/17
to RavenDB - 2nd generation document database
Maybe because your code is running in the same thread/session? My code runs over an http request, so the first read is over one session/thread, the write in another and the next read on another one...

Oren Eini (Ayende Rahien)

unread,
Oct 11, 2017, 3:46:25 PM10/11/17
to ravendb
Are you using a sync session?

To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Oct 11, 2017, 4:04:16 PM10/11/17
to RavenDB - 2nd generation document database
No. Async all the way. Is there any way I can help debugging this? I'm attaching a fiddler session where you can see the issue...
Raven.saz

Oren Eini (Ayende Rahien)

unread,
Oct 12, 2017, 2:23:39 PM10/12/17
to ravendb
AggresiveCaching value is stored in AsyncLocal, so I don't think that there should be anything related to this.
I tried repoducing this, and I can't.

 static async Task MainAsync()
        {
            var documentStore = new DocumentStore
            {
                Urls = new[] {"http://4.live-test.ravendb.net"},
                Database = "Test"
            };
         
            documentStore.Initialize();

            while (true)
            {
                using (var s = documentStore.OpenAsyncSession())
                {
                    dynamic load;
                    using (documentStore.AggressivelyCache())
                    {
                        load = await s.LoadAsync<dynamic>("users/1");
                    }
                    Console.WriteLine(load.Name);
                    Console.WriteLine(documentStore.GetRequestExecutor().NumberOfServerRequests);
                }
                Console.ReadLine();
            }
        }


Can you try reproing this on your end?
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Marcelo Volmaro

unread,
Oct 17, 2017, 2:11:03 PM10/17/17
to RavenDB - 2nd generation document database
Oren, is there a place where I can send you the project? I can reproduce the issue with two different projects I have, but tried to create a simple test but I'm not able to repro the issue on that test.
I would need to send both the project and some .dlls that are really from an internal nuget feed so maybe you might need to adjust the references (I can't provide access to the nuget feed)...

Is that ok for you?

Oren Eini (Ayende Rahien)

unread,
Oct 18, 2017, 1:57:43 AM10/18/17
to ravendb
sup...@ravendb.net is the best location.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages