Exception in SQL Replication breaking bulk_docs

51 views
Skip to first unread message

Gareth Thackeray

unread,
Jul 21, 2014, 5:28:30 AM7/21/14
to rav...@googlegroups.com
We saw an exception in SQLReplicationTask that caused a 500 in a bulk_docs call, but the transaction completed, so the data in bulk_docs was saved.  Any idea what could be causing this?

Url: "/bulk_docs"

System.NullReferenceException: Object reference not set to an instance of an object.
   at Raven.Database.Bundles.SqlReplication.SqlReplicationTask.<>c__DisplayClass9.<RecordDelete>b__7(IStorageActionsAccessor accessor)
   at Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action`1 action, EsentTransactionContext transactionContext)
   at Raven.Storage.Esent.TransactionalStorage.Batch(Action`1 action)
   at Raven.Database.Bundles.SqlReplication.SqlReplicationTask.RecordDelete(String id, RavenJObject metadata)
   at Raven.Database.Bundles.SqlReplication.SqlReplicationTask.<Execute>b__0(DocumentDatabase sender, DocumentChangeNotification notification, RavenJObject metadata)
   at System.Action`3.Invoke(T1 arg1, T2 arg2, T3 arg3)
   at System.Action.Invoke()
   at Raven.Storage.Esent.TransactionalStorage.Batch(Action`1 action)
   at Raven.Database.DocumentDatabase.Batch(IList`1 commands)
   at Raven.Database.Server.Responders.DocumentBatch.Batch(IHttpContext context)
   at Raven.Database.Server.Responders.DocumentBatch.Respond(IHttpContext context)
   at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx)
   at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)       at Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e)
   at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1 getResponse)
   at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson()
   at Raven.Client.Connection.ServerClient.DirectBatch(IEnumerable`1 commandDatas, OperationMetadata operationMetadata)
   at Raven.Client.Connection.ReplicationInformer.TryOperation[T](Func`2 operation, OperationMetadata operationMetadata, OperationMetadata primaryOperationMetadata, Boolean avoidThrowing, T& result, Boolean& wasTimeout)
   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()

Gareth Thackeray

unread,
Jul 21, 2014, 5:29:07 AM7/21/14
to rav...@googlegroups.com
Build 2879

Gareth Thackeray

unread,
Jul 21, 2014, 5:42:58 AM7/21/14
to rav...@googlegroups.com
It turns out this is happening on every delete.


On Monday, July 21, 2014 10:28:30 AM UTC+1, Gareth Thackeray wrote:

Grisha Kotler

unread,
Jul 21, 2014, 7:14:40 AM7/21/14
to rav...@googlegroups.com
Found and fixed the problem, it will be in the next build.

It happened if the data in bulk_docs contained operations on sql replications documents where at least one of the operations was a delete.

Grisha Kotler

RavenDB Core Team

Tel: 972-4-6227811

Fax: 972-153-4-6227811





--
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.

Gareth Thackeray

unread,
Jul 21, 2014, 7:27:43 AM7/21/14
to rav...@googlegroups.com
Amazing service - thanks!  Any idea how I could prevent this actually occurring again before we get a chance to upgrade?

Oren Eini (Ayende Rahien)

unread,
Jul 21, 2014, 10:18:32 AM7/21/14
to ravendb
You can avoid updating the sql replication in the same batch as other stuff.



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811



Grisha Kotler

unread,
Jul 21, 2014, 10:45:43 AM7/21/14
to rav...@googlegroups.com
Avoid deleting sql replications in a batch operation.
--

Gareth Thackeray

unread,
Jul 23, 2014, 12:12:00 PM7/23/14
to rav...@googlegroups.com
Thanks again for the fix.  I just want to ask though: this error in a bundle caused an exception on calling SaveChanges() in the client, although it had saved the data.  This meant we didn't send associated emails about the action (an order being placed).  This seems broken to me - perhaps there should be a success with info about bundle problems return?  (Or the transaction should be rolled back if that is possible?)

Oren Eini (Ayende Rahien)

unread,
Jul 24, 2014, 3:27:17 AM7/24/14
to ravendb
The transaction was rolled back.



Oren Eini

CEO


Mobile: + 972-52-548-6969

Office:  + 972-4-622-7811

Fax:      + 972-153-4622-7811





Gareth Thackeray

unread,
Jul 24, 2014, 3:39:30 AM7/24/14
to <ravendb@googlegroups.com>
We have the order in our database though.


--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/MwIwxXfdIUw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gareth Thackeray

Co-founder

Code Trip
Online Marketplaces | Bespoke Development




Oren Eini (Ayende Rahien)

unread,
Jul 24, 2014, 3:42:41 AM7/24/14
to ravendb
Oh, sorry, you are correct.
This event is actually raised _after_ the transaction has been committed, but before we return to the client.

Gareth Thackeray

unread,
Jul 24, 2014, 3:56:44 AM7/24/14
to <ravendb@googlegroups.com>
Which means potentially bad news right?  You could consider returning something like this http://stackoverflow.com/a/8474782

Oren Eini (Ayende Rahien)

unread,
Jul 24, 2014, 4:03:11 AM7/24/14
to ravendb
Since this is a bug in our code, which was fixed, it isn't really something that we look at.

Gareth Thackeray

unread,
Jul 24, 2014, 5:56:50 AM7/24/14
to <ravendb@googlegroups.com>
Well obviously it's your code and your decision, but the fact that a bundle (which might not be your code) can make a SaveChanges() call report failed when actually it succeeded doesn't sound very "safe by default".  Not to mention that evidently it is possible for even the core bundles to contain such a fault.

Oren Eini (Ayende Rahien)

unread,
Jul 24, 2014, 6:23:13 AM7/24/14
to ravendb
A bundle can do a LOT of things that would mess things up. We aren't trying to protect ourselves from Bundles, because that isn't realy possible.
Reply all
Reply to author
Forward
0 new messages