Could not replicate POST operation to secondary node, failover behavior is: AllowReadsFromSecondaries

365 views
Skip to first unread message

Kenneth Truyers

unread,
Oct 16, 2014, 5:53:27 AM10/16/14
to rav...@googlegroups.com
When we are calling SaveChanges on the DocumentSession, every now and then we get the following exception:

System.InvalidOperationException: Could not replicate POST operation to secondary node, failover behavior is: AllowReadsFromSecondaries
   at Raven.Client.Connection.ReplicationInformer.AssertValidOperation(String method)
   at Raven.Client.Connection.ReplicationInformer.ShouldExecuteUsing(String operationUrl, Int32 currentRequest, String method, Boolean primary)
   at Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication[T](String method, String primaryUrl, OperationCredentials primaryCredentials, Int32 currentRequest, Int32 currentReadStripingBase, Func`2 operation)
   at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func`2 operation)
   at Raven.Client.Document.DocumentSession.SaveChanges()

Could someone tell me what this exception is about? 
Is it that the secondary node is not available? If so, why does it do this synchronously, shouldn't it be doing this asynchronously? Otherwise we'd need all nodes to be online when writing to the DB.

Note: Sometimes it's PUT, sometimes POST, if that makes a difference.

Oren Eini (Ayende Rahien)

unread,
Oct 16, 2014, 6:00:20 AM10/16/14
to ravendb

The default replication setting only replicate reads, you need to explicitly define the conventions fail over behavior to allow fail over of read And write
And your servers should be set as master/master

--
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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kenneth Truyers

unread,
Oct 16, 2014, 7:25:21 AM10/16/14
to rav...@googlegroups.com
We have it setup as master-slave, because we don't want to failover on write.

What is the error here then? That the main database is not available?
This happens quite often so I don't think that is the case.

Oren Eini (Ayende Rahien)

unread,
Oct 16, 2014, 7:28:35 AM10/16/14
to ravendb

The only reason this particular error will happen is when the primary is not available for some reason

Kenneth Truyers

unread,
Oct 16, 2014, 9:53:40 AM10/16/14
to rav...@googlegroups.com
OK, thanks.

Is it possible to configure one client to only allow reads from the master while allowing another client to read from any node?

Oren Eini (Ayende Rahien)

unread,
Oct 16, 2014, 1:08:20 PM10/16/14
to ravendb
Yes, look at the FailoverBehavior property on store.Conventions

Hibernating Rhinos Ltd  

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

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

 

Kenneth Truyers

unread,
Oct 17, 2014, 9:36:01 AM10/17/14
to rav...@googlegroups.com
Looking further into this, today this happened twice while I'm certain that the master database was available.
I can reproduce this at the moment, so this also happens sometimes when the primary is available.

Oren Eini (Ayende Rahien)

unread,
Oct 17, 2014, 9:40:42 AM10/17/14
to ravendb
Enable Fiddler, what do you see there?

Kenneth Truyers

unread,
Oct 17, 2014, 9:57:53 AM10/17/14
to rav...@googlegroups.com
This is our production environment, I can't just install fiddler there. Is there a log on the server for all incoming requests?

Oren Eini (Ayende Rahien)

unread,
Oct 17, 2014, 10:00:14 AM10/17/14
to ravendb
If you have enabled debug, yes. Or if you are running in IIS, enable IIS logging.
But note that this is the _client_ connecting there. you can try this from your own machine
Reply all
Reply to author
Forward
0 new messages